I am trying to do some descriptives on my own location data that I got from my Google timeline. But when trying to get some workable data, to convert it from a JSON-file to a DataFrame. It brought up some questions that I would like to have some answers to because when trying to convert the JSON-file to a DataFrame it felt for me that I was going to do it in an inefficient way.
To give a description of what my JSON looks like. It is a JSON of 3 levels deep and has around 4.5 million lines. A small example of the JSON:
"locations" : [
{
"timestampMs" : "1489591483",
"latitudeE7" : -21.61909,
"longitudeE7" : 121.65283,
"accuracy" : 23,
"velocity" : 18,
"heading" : 182,
"altitude" : 55,
"activity" : [ {
"timestampMs" : "1489591507",
"activity" : [ {
"type" : "IN_VEHICLE",
"confidence" : 49
}, {
"type" : "UNKNOWN",
"confidence" : 17
}, {
"type" : "ON_BICYCLE",
"confidence" : 15
}, {
"type" : "ON_FOOT",
"confidence" : 9
}, {
"type" : "STILL",
"confidence" : 9
}, {
"type" : "WALKING",
"confidence" : 9
} ]
} ]
},
...
]
To convert it to a DataFrame I want to flatten those 3 levels down to 0 levels. I have seen some implementations with json_normalize in combination with .apply or .append but therefore you still needed to know the key to the value, which I would have rather seen to be more generic (so without knowing the key). And it also required to manually iterate over the values. Now what I would like to know is: "Is there a method that automatically flattens the JSON down to 0 levels without using apply or append?" If there isn't such a method, what would be the preferred way of flatting JSON and converting it to a DataFrame?
Edit: Added an example of what the DataFrame should look like and a better example of the JSON.
To give a small example of what the DataFrame should look like, see the image below:

To include a better example of what the JSON looks like I have included a Pastebin URL below: tiny location history sample
