I would like to convert a JSON to Pandas dataframe.
My JSON looks like: like:
{
\"country1\":{
\"AdUnit1\":{
\"floor_price1\":{
You can try this approach:
from google.cloud import storage
import pandas as pd
storage_client = storage.Client()
bucket = storage_client.get_bucket('test-mvladoi')
blob = bucket.blob('file')
read_output = blob.download_as_string()
data = json.loads(read_output)
data_norm = json_normalize(data, max_level=5)
df = pd.DataFrame(columns=['col1', 'col2', 'col3', 'col4', 'col5'])
i = 0
for col in b.columns:
a,c,d,e = col.split('.')
df.loc[i] = [a,c,d,e,b[col][0]]
i = i + 1
print(df)