DECROMAX

Explode list of dict column (with key)

May 11th, 2022
1,206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. # Explodes df column containing list of dict to dataframe with key col
  2.  
  3. df_in = df.set_index('key_col')['list_of_dict'].explode()
  4. df_out = pd.DataFrame(df_in.tolist(), index=df_in.index).reset_index()
Advertisement
Add Comment
Please, Sign In to add comment