#pandas #dataframe
Вопрос:
я пытаюсь сохранить выходные данные моего цикла с помощью некоторых данных json во фрейме данных pandas, но каждый раз, когда я пытаюсь это сделать, я просто получаю одну строку фрейма данных.
мой вопрос: как я могу заполнить все строки в кадре данных вместо 1?
ps — в приведенном ниже коде я удалил попытку сохранения в df, которая сохранила только одну строку
код:
import requests
# import lxml
import json, time
import pandas as pd
import schedule
from datetime import datetime
from pandas import json_normalize
url = "https://api.opensea.io/wyvern/v1/orders"
querystring = {"bundled":"false","include_bundled":"false","include_invalid":"false","side":"0","sale_kind":"0","limit":"50","offset":"0","order_by":"created_date","order_direction":"desc"}
headers = {"Accept": "application/json"}
response = requests.request("GET", url, headers=headers, params=querystring)
json_string = response.text # this used to be print(response.data) but i added it to data
json_dict = json.loads(json_string)
orders = json_dict['orders']
count = json_dict['count']
columns = ['name', 'link', 'discord']
data = []
df = []
for items in orders:
asset = items['asset']
asset_contract = asset["asset_contract"]
collection = asset['collection']
print("==========================")
name = asset_contract['name']
print(name)
nftlink = asset['permalink']
print('buy link: ' nftlink)
slug = collection['slug']
collection_link = 'collection: https://opensea.io/collection/' slug
print(collection_link)
discord = str(collection['discord_url'])
print('discord: ' discord)
twitter = str(collection['twitter_username'])
print('twitter: https://twitter.com/' twitter)
owner_dict = asset['owner']
user_dict = owner_dict['user']
longprice = float(items['current_price']) # need to move the decimal 18 places over, then converted to float
price = str(longprice/1000000000000000000) #converted to float then divide 18 decimals
print('latest bid = ' price ' eth')