I'm trying to process a JSON file containing google location history data and am trying to put all the data points into a dataframe. I am using this code as reference (https://github.com/nurkiewicz/google-location-history/blob/master/Google%20location%20history.ipynb). However, I encounter this error:
return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'locations'
This is my code:
import pandas as pd
import numpy as np
import geopandas as gp
import shapely.geometry as sg
import datetime as dt
from matplotlib import cm
from matplotlib.lines import Line2D
def parse_json(json):
points = [sg.Point(xy) for xy in zip(json.locations.apply(lambda x: x["longitudeE7"] / 10000000),
json.locations.apply(lambda x: x["latitudeE7"] / 10000000))]
df = gp.GeoDataFrame(geometry=points)
return df
df = parse_json(pd.read_json("2022_MAY.json"))
This is what the location history looks like: enter image description here
I'm still new to Python so I'm unsure how to resolve this issue?
I tried debugging the code to go through the json but wasn't really sure what was going wrong.