I\'m reading data from a database (50k+ rows) where one column is stored as JSON. I want to extract that into a pandas dataframe. The snippet below works fine but is fairly
I think you can first convert string
column data
to dict
, then create list
of numpy arrays
by values and last DataFrame.from_records:
df = pd.read_csv('http://pastebin.com/raw/7L86m9R2', \
header=None, index_col=0, names=['data'])
a = df.data.apply(json.loads).values.tolist()
print (pd.DataFrame.from_records(a))
Another idea:
df = pd.json_normalize(df['data'])