Код: Выделить всё
import requests
import pandas as pd
url = "https://api.blockchain.info/charts/transaction-fees?timespan=all&format=json"
response = requests.get(url)
data = response.json()
df = pd.DataFrame(data['values'])
# Convert the timestamp to a readable format
df['x'] = pd.to_datetime(df['x'], unit='s') # 'x' is the Unix timestamp
df.set_index('x', inplace=True) # Set the datetime as the index
df.rename(columns={'y': 'fees'}, inplace=True) # Rename 'y' to 'hashrate'
print(df.head())
Код: Выделить всё
import requests
import pandas as pd
url = "https://api.blockchain.info/charts/transaction-fees?timespan=all&rollingAverage=4days&format=json"
response = requests.get(url)
data = response.json()
df = pd.DataFrame(data['values'])
# Convert the timestamp to a readable format
df['x'] = pd.to_datetime(df['x'], unit='s')
df.set_index('x', inplace=True)
df.rename(columns={'y': 'fees'}, inplace=True) # Rename 'y' to 'hashrate'
df_daily = df.resample('D').interpolate(method='linear')
print(df_daily.head())
Я предполагаю, что это ограничение API. Поскольку необработанные данные также каждый раз пропускают 3 дня: https://api.blockchain.info/charts/transaction-fees
-- Обновление 2
Я добавил «выборку» =false» на запрос API, и теперь я получаю данные каждые 15 минут, что слишком много. Я просто ищу ежедневные данные, но документация API не очень хороша:
https://www.blockchain.com/explorer/api/charts_api
Подробнее здесь: https://stackoverflow.com/questions/790 ... ery-4-days