My API generates a JSON file as output with the following structure:
[
{
"Data": {
"SensorId": "EF00BFC0",
"SensorName": "DEVICE 05",
"TimeStamp": 3877552823,
},
"ThresholdValue": {
"SensorSubId": 1,
"ThresholdMax": -1,
"ThresholdMin": -1
},
"startUTC": 1668564000,
"endUTC": 1668663000
},
{
"Data": {
"SensorId": "EF00BFC0",
"SensorName": "DEVICE 05",
"TimeStamp": 3877553446,
},
"ThresholdValue": {
"SensorSubId": 1,
"ThresholdMax": -1,
"ThresholdMin": -1
},
"startUTC": 1668564000,
"endUTC": 1668663000
}]
I want to generate a Pandas DataFrame with SensorID, SensorName, Timestamp, startUTC, and endUTC as columns. I tried it using the below code.
df_nested_list = pd.json_normalize(
data,
record_path =['Data'],
meta=['startUTC', 'endUTC']
)
But it gives the column names as rows and generate the dataframe. How can I do this in pandas?
df=pd.json_normalize(data)?