I have JSON of the form:
{
"abc":
{
"123":[45600,null,3567],
"378":[78689,2345,5678],
"343":[23456,null,null]
}
}
I have got json data from a url using below way:
json_data = json.loads(url.read().decode())
I need to convert it into Python Pandas Dataframe as below:
ds y_ds1 y_ds2 y_ds2
123 45600 null 3567
378 78689 2345 5678
343 23456 null null
I'm trying to do this way :
df = pd.read_json(url,orient='columns')
It gives result in following form:
abc
123 [45600,null,3567]
378 [78689,2345,5678]
343 [23456,null,null]
Any way by which I can simply split my second column of array into no. of columns present in the array and rename the headings as mentioned above?
Edits: According to the given json, there are 3 elements in all the arrays; what if the array size is 2 or 4 or 5 for all the items. Note: JSON will have all keys with similar sized arrays. But size of array can be anything.