我正在尝试将原始日期转换为数据框,然后将其放入烛台中,但是经过数小时的搜索,我得到了奇怪的结果。轴显示的是从1970年开始的日期(从2018年开始),我的烛台是红色和绿色的大海洋
每条建议都值得赞赏!谢谢大家阅读
代码:
start = "1 April, 2018"
end = "24 May 2019"
df = client.get_historical_klines("BTCUSDT", Client.KLINE_INTERVAL_1DAY, start, end)
df = pd.DataFrame(df)
pd.set_option('display.max_columns', 500)
df = df.rename(columns = {0: "Date",
1:"Open",
2: "High",
3:"Low",
4:"Close",
5:"Volume",
6:"Close time",
7:"Quote asset volume",
8:"Number of trades",
9:"Taker buy asset volume",
10:"Taker buy quote asset volume",
11:"Can be ignored"})
df["Date"]=pd.to_datetime(df["Date"])
df["Date"]=mdates.date2num(df["Date"])
df["Open"]=pd.to_numeric(df["Open"])
df["High"]=pd.to_numeric(df["High"])
df["Low"]=pd.to_numeric(df["Low"])
df["Close"]=pd.to_numeric(df["Close"])
ax = plt.subplot()
candlestick_ohlc(ax, df.values, width=5, colorup='g', colordown='r')
ax.xaxis_date()
ax.grid(True)
plt.show()