One column of my dataframe its in the following format:
{'name': 'Aimo'}
{'name': 'Aimo'}
{'name': 'Aimo'}
{'name': 'Aimo'}
{'name': 'Aimo'}
The dtype
of the column is object
. How can I modify this column in the following format?
Aimo
Aimo
Aimo
Aimo
Aimo
Probably the new dtype
would be character
. Thank you in advance!
CodePudding user response:
I guess if they're dictionaries, do:
df['column'] = df['column'].str['name']
Or parse them as dictionaries if they are not already:
from ast import literal_eval
df['column'] = df['column'].map(literal_eval).str['name']
CodePudding user response:
Use Series.str.get
:
df['column'] = df['column'].str.get('name')