I have a pandas DataFrame df
with a column latlng
.
The rows in this column have the format
{'latitude': '34.041005', 'longitude': '-118.249569'}
.
In order to be able to add markers to a map (using folium librairie), I would like to create two columns 'latitude'
and longitude
which in this example would contain respectively 34.041005
and -118.249569
.
EDIT: Managed to have it working with this first step: df['latlng'] = df['latlng'].map(eval)
You can use
pd.json_normalize
to avoidapply
which is costly:Then you can concat these columns back to
df
like below: