Skip to content

Instantly share code, notes, and snippets.

@nkthiebaut
Created March 23, 2020 20:13
Show Gist options
  • Save nkthiebaut/86e549f00385ca142d1657a1b06bff4c to your computer and use it in GitHub Desktop.
Save nkthiebaut/86e549f00385ca142d1657a1b06bff4c to your computer and use it in GitHub Desktop.
Pandas : column of JSON strings to DataFrame
# inspired by https://stackoverflow.com/a/50658993/5174617
import pandas as pd
import json
df = pd.DataFrame([['0 {"a":"1","b":"2","c":"3"}'],['1 {"a" :"4","b":"5","c":"6"}']], columns=['json'])
exploded_df = df['json'].apply(json.loads).apply(pd.Series)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment