I have the following pandas dataframe:
import pandas as pd
df = pd.DataFrame({'NAME': ['Paris', 'New York', 'Rio'],
'GEO': ['POINT (48.85 2.31647)',
'POINT (40.731499671618 -73.993457389558)',
'POINT (-22.9 -43.2)']})
print(df)
NAME GEO
Paris POINT (48.85 2.31647)
New York POINT (40.731499671618 -73.993457389558)
Rio POINT (-22.9 -43.2)
I need to separate the GEO column into two columns. One column to store latitude and another column to store longitude.
So, based on this code: Adding Lat Lon coordinates to separate columns (python/dataframe) , I implemented the following:
df['GEO'].str('POINT ()').str.strip(' ', expand=True).rename(columns={0:'LAT', 1:'LONG'})
However, it is giving the error: "TypeError: 'StringMethods' object is not callable"
I would like the output to be:
NAME GEO LAT LONG
Paris POINT (48.85 2.31647) 48.85 2.31647
New York POINT (40.731499671618 -73.993457389558) 40.731499671618 -73.993457389558
Rio POINT (-22.9 -43.2) -22.9 -43.2