【发布时间】:2021-05-29 18:56:36
【问题描述】:
我想从 binance 获取 klines 数据并在 excel 上制作。但是有错误发生。 这是我的代码
import pandas as pd
from binance.client import Client
api_key = 'my api key'
api_secret = 'my api key'
client = Client(api_key, api_secret)
klines = client.get_historical_klines('BTCUSDT', Client.KLINE_INTERVAL_1MINUTE, '28 MAY, 2021')
whole_df = pd.DataFrame(klines)
whole_df.columns = ['Open_time','open','high','low','close','volume','Close_time', 'Quote asset volume', 'number of trades', 'Taker buy base asset volume', 'Taker buy quote asset volume', 'Ignore']
whole_df = whole_df.drop_duplicates(subset=['Open_time'], keep=False)
whole_df = whole_df.convert_objects(convert_numeric=True)
whole_df.to_csv('binance_BTCUSDT_data.csv', encoding='utf-8')
exit()
and the error is
File "C:/Users/y/PycharmProjects/untitled/test.py", line 13, in <module>
whole_df = whole_df.convert_objects(convert_numeric=True)
File "C:\Users\y\PycharmProjects\untitled\venv\lib\site-packages\pandas\core\generic.py", line 5465, in __getattr__
return object.__getattribute__(self, name)AttributeError: 'DataFrame' object has no attribute 'convert_objects'
【问题讨论】:
-
您看到的错误有什么不清楚的地方?