From 21804923a59c3c903c4d6df347be0a59daf229ea Mon Sep 17 00:00:00 2001 From: spbeach46 Date: Wed, 30 Sep 2020 23:50:36 -0700 Subject: [PATCH] constructing dataframe from json semi-manually --- shopping_test.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shopping_test.py b/shopping_test.py index 13145d9..862bccf 100644 --- a/shopping_test.py +++ b/shopping_test.py @@ -1,7 +1,7 @@ import requests import json from bs4 import BeautifulSoup as b - +import pandas as pd params = { "callname":"GetMultipleItems", @@ -16,4 +16,12 @@ response = requests.get("https://open.api.ebay.com/shopping?", params=params) # data = response.json() pretty_data = json.dumps(data, indent=2) +df = pd.read_json(data, 'Item') +nvl = df.iloc[0]['ItemSpecifics.NameValueList'] +nvl_dict = {} +for item in nvl: + nvl['Name'] # departments = ["3034","93427"] +# Best plan of action is probably json-->pandas df. You can decide how to clean later, but it +# will prolly be easier if you clean in pandas because you can drop columns easily that you don't +# need. Figure out how to "flatten" your json data into the df first.