情节包括x轴中数据中缺少的日期
拥有财务数据,周末/银行假期等没有数据。在下面的示例中,我使用此数据集。
假设具有dateFrame,其中索引由时间戳组成,然后天真地使用:
import pandas as pd
pd.options.plotting.backend = "plotly"
fig = df["open"].plot()
返回:
很棒……除了连接丢失数据的直线。添加:
fig.update_layout(xaxis=dict(type="category"))
几乎是完美的:
我现在如何获得相同的脚注(年,每天,每天没有时间)?一旦将索引视为类别,我就可以无法使用%b
和CO的日期格式。
Having financial data, there is no data over weekends/bank holidays/etc. In the example below I used this data set.
Assume having a dateframe where the index consists of timestamps then naively plotting the data using:
import pandas as pd
pd.options.plotting.backend = "plotly"
fig = df["open"].plot()
returns:
which is great... except the straight lines connecting the missing data. Adding:
fig.update_layout(xaxis=dict(type="category"))
Is almost perfect:
How can I now get the same tickers (Year, Month, day without the hours)? Once the index is treated as a category then I cannot use date formatter like %b
and co.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论