简体   繁体   English

如何绘制此时间序列?

[英]How do I plot this time series?

I am trying to plot this time series in a chart, but the canvas is empty. 我试图在图表中绘制此时间序列,但画布为空。

我的代码的屏幕截图 As you can see in the image above, my time series is quite simple. 如上图所示,我的时间序列非常简单。 I want to plot DATE in x-axis and PAYEMS in the y-axis. 我想在x轴上绘制DATE,在y轴上绘制PAYEMS。

At first, I was getting an error because my dates were strings, so I converted it in cell 11. 起初,我因为日期是字符串而遇到错误,所以我在单元格11中对其进行了转换。

You do not want to use a tsplot to plot a time series. 您不想使用tsplot绘制时间序列。 The name is a bit confusing, but as the documentation puts it, tsplot is "intended to be used with data where observations are nested within sampling units that were measured at multiple timepoints" . 这个名称有点tsplot困惑,但是正如文档所说, tsplot“旨在用于将观察嵌套在多个时间点测量的采样单元中的数据使用” As a rule of thumb: If you understand this sentence, you will know when to use it, if you don't understand this sentence, don't use it. 根据经验:如果您理解此句子,您将知道何时使用它;如果您不理解此句子,请不要使用它。 Apart, tsplot will even be removed or significantly altered in the future, so its use is deprecated. 此外, tsplot将来甚至会被删除或进行重大更改,因此不建议使用。

But that doesn't matter, because you can directly use pandas to plot the time series. 但这没关系,因为您可以直接使用熊猫绘制时间序列。

df.plot(x="Date", y="Payems")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM