Issue
I have csv file , which have one column and inside this column have string , string contains many values , i want to convert this string in muultiple columns
here is example data:
df = pd.DataFrame({'column1':[{'A':2,'B':3,'c':2}]})
print(df)
column1
0 {'A': 2, 'B': 3, 'c': 2}
1 {'A': 3, 'B': 5, 'c': 10}
i want output:
df = pd.DataFrame({'A':[2],'B':[3],'c':[2]})
Solution
try this:
pd.DataFrame([*df['column1'].apply(eval)])
Answered By - ziying35
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.