I am trying to download my youtube data using the Youtube Analytics and Reporting API from here Google Reference. I am using Python code from google to download this data which works fine. The data is retrieved in JSON format As shown below.
rawdata.json -
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "day",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "estimatedMinutesWatched",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "averageViewDuration",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "averageViewPercentage",
"columnType": "METRIC",
"dataType": "FLOAT"
},
{
"name": "subscribersGained",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"rows": [
[
"2020-10-01",
445,
1068,
144,
38.78,
3
],
[
"2020-10-02",
406,
905,
133,
34.94,
2
],
[
"2020-10-03",
466,
1042,
134,
34.77,
6
],
[
"2020-10-04",
427,
1006,
141,
36.48,
3
],
[
"2020-10-05",
379,
964,
152,
39.48,
2
]
]
}
I am trying to convert this JSON into CSV format but having no luck so far.
Here is the python code I am using to normalize and create a data frame but having no luck.
import json
import pandas as pd
from pandas import json_normalize
with open('rawdata.json') as json_file:
data = json.load(json_file)
#print (data)
df = json_normalize(data['rows'])
print(df)
I am trying to get the final output in this format. 
Any help or guidance is much appreciated.
EDIT: Answer by Suraj S. This worked out for me.
import json
import pandas as pd
from pandas import json_normalize
with open('rawdata.json') as json_file:
data = json.load(json_file)
#print (data)
df = pd.DataFrame(data['rows'],columns=['day','views','comments','likes','dislikes','estimatedMinutesWatched','averageViewDuration','subscribersGained'])
print(df)