How to convert the below in pandas :
To
Here is my answer : The data I had was a nested json :
The json I had consist of a row containing a Json , which when normalized contained another json . Below I have normalized the entire json into a dataframe.
import json
import pandas as pd
from pandas.io.json import json_normalize
#Load Json to DF
with open(r"C:\Users\data\Collection.json") as f:
data = json.load(f,strict=False)
deep_df = pd.DataFrame(data)
deep_df.head
df_s1= json_normalize(deep_df.data.loc["mdata"])
df_s1.rename(columns={"docId": "docId_head", "id_colId": "id_colId_head"},inplace='True')
df_s2 = df_s1.set_index(['docId_head', 'id_colId_head','moref','objType'])
df_s3=pd.DataFrame()
for idx in df_s2['values'].index:
#print(idx[0])
df_s3=df_s3.append(json_normalize(df_s2['values'][idx]).drop('docId',axis=1).set_index(['retrievePath']).T.reset_index().join(pd.DataFrame(df_s2.index[idx[0]-1]).T),sort=False)