I have a data pull from an API, and I can get the return flattened only to a certain extent using pd.json_normalize. here is a sample of the python df.object
odds_df=pd.DataFrame(odds_dict)
id commence_time home_team away_team bookmakers
1. 2022-09-09T00:20:00Z Los Angeles Rams Buffalo Bills [{'key': 'unibet','title': 'Unibet', 'last_up...
I can get the bookmark portion normalized to this point
pd.json_normalize(odds_dict,["bookmakers",["markets"]])
key outcomes
0 spreads [{'name': 'Buffalo Bills', 'price': 1.91, 'poi...
1 spreads [{'name': 'Buffalo Bills', 'price': 1.9, 'poin...
But if I try to godown one more level using Json_normalize, it keeps throwing an error. This is how I am trying to use it:
pd.json_normalize(odds_dict,["bookmakers",["markets",["outcomes"]]])
TypeError: list indices must be integers or slices, not list
It seems like it should work by inserting "outcomes" in the same format that I had markets. I looked up the documentation in pandas but it is neither descriptive nor do the examples really show case like this.