I have a dictionary where the keys are GitHub repository names and the values contain JSON-formatted data.
ex:
{'r1':[
{'id': 1178421030,
'name': 'x',
},
{'id': 1178420990,
'name': 'y',
}],
'r2':[
{'id': 1178421031,
'name': 'a',
},
{'id': 1178420950,
'name': 'b',
}]
}
I can create a dataframe from the JSON the values in the dict using:
df=pd.DataFrame()
for i in responses:
df=df.append(pd.json_normalize(responses[i]))
This gives me a df that looks like this:
id name
1178421030 x
1178420990 y
1178421031 a
1178420950 b
I want the keys of the dict as another column named repo_name in the df, something like:
id name repo_name
1178421030 x r1
1178420990 y r1
1178421031 a r2
1178420950 b r2
how shall I go about doing this ?