0

I have the following pandas dataframe:

enter image description here

The field '_source' has a JSON structure in the content. I'd like to convert this field in another dataframe with the correspondent columns.

The type of this field is Series:

type(df['_source']) 
   pandas.core.series.Series

Which is the best way to convert this field ('_source') in a Pandas DataFrame?

Thanks in advance

Kind regards

Dario R
  • 63
  • 1
  • 10
  • Finally this post help me to solve what I want : https://stackoverflow.com/questions/21104592/json-to-pandas-dataframe – Dario R Mar 05 '19 at 18:00

1 Answers1

1

You can use these lines of code to convert '_source' in correspondent columns:

subdf= df['_source'].apply(json.loads)
pd.DataFrame(subdf.tolist())
F Blanchet
  • 1,430
  • 3
  • 21
  • 32