df =
multi
0 MULTIPOLYGON(((3 11, 2 33)))
1 MULTIPOLYGON(((4 22, 5 66)))
I was trying to remov
You can use df.column.str in the following way.
df['a'] = df['a'].str.findall(r'[0-9.]+')
df = pd.DataFrame(df['a'].tolist())
print(df)
output:
0 1
0 3.49 11.10
1 4.49 22.12
This will work for any number of columns. But in the end you have to name those columns.
df.columns = ['a'+str(i) for i in range(df.shape[1])]
This method will work even when some rows have different number of numerical values. like
df =pd.DataFrame({'a':['MULTIPOLYGON(((3.49)))' ,'MULTIPOLYGON(((4.49 22.12)))']})
a
0 MULTIPOLYGON(((3.49)))
1 MULTIPOLYGON(((4.49 22.12)))
So the expected output is
0 1
0 3.49 None
1 4.49 22.12
After naming the columns using,
df.columns = ['a'+str(i) for i in range(df.shape[1])]
You get,
a0 a1
0 3.49 None
1 4.49 22.12