Transform Dataframe From Request Into Structured Format
I have a request from a website stored in a dataframe with one column that looks like this (each line is a new row): request {'Title':'Birds','Year':'2019','Rated':'R','Runtime':'1
Solution 1:
use ast.literal_eval
to parse the strings, then unpack with pd.DataFrame
:
import ast
pd.DataFrame(df['request'].map(ast.literal_eval).tolist())
Title Year Rated Runtime
0 Birds 2019 R 122 min
1 Chernob 2019 R 111 min
2 Fame 2019 R NaN
Post a Comment for "Transform Dataframe From Request Into Structured Format"