how to explode a nested dictionary from a dataframe column
Question:
Answers:
You can use pandas.Series.explode
with pandas.DataFrame
constructor :
#if need to evalute the column as lists of dict
#from ast import literal_eval
#df["genres"] = df["genres"].apply(literal_eval)
genres = pd.DataFrame(df.pop("genres").explode().tolist())
You can use pandas.Series.explode
with pandas.DataFrame
constructor :
#if need to evalute the column as lists of dict
#from ast import literal_eval
#df["genres"] = df["genres"].apply(literal_eval)
genres = pd.DataFrame(df.pop("genres").explode().tolist())