Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何绘制显示数据变化量的时间序列?_Python_Pandas_Numpy_Plot_Visualization - Fatal编程技术网

Python 如何绘制显示数据变化量的时间序列?

Python 如何绘制显示数据变化量的时间序列?,python,pandas,numpy,plot,visualization,Python,Pandas,Numpy,Plot,Visualization,例如,我有如下数据: 18:00:00 0 18:00:01 -1 18:00:02 -1 18:00:03 -1 18:00:04 2 18:00:05 -3 18:00:06 1 18:00:07 2 18:00:08 3 18:00:09 4 18:00:10 5 18:00:11 4 18:00:12 3 18:00:13 -1 18:00:14 2 18:00:15 8

例如,我有如下数据:

18:00:00     0
18:00:01    -1
18:00:02    -1
18:00:03    -1
18:00:04     2
18:00:05    -3
18:00:06     1
18:00:07     2
18:00:08     3
18:00:09     4
18:00:10     5
18:00:11     4
18:00:12     3
18:00:13    -1
18:00:14     2
18:00:15     8
18:00:16    11

我想根据以下几点画波浪:

(-1,18:00:03)
(2,18:00:04)
(-3,18:00:05)
(5,18:00:10)
(-1,18:00:13)
(11,18:00:16)

有没有简单的方法可以做到这一点?

我想我知道如何选择点。根据值符号的变化,可以使用创建组​​这是本系列的第一部

要区分组,可以使用+。我留下了用于组成分组的序列结果的细节

然后我创建了一个函数来获取这些值​​根据我认为你想要采用的标准,并且已经通过了应用


输出图像:


细节

groups

2019-10-18 18:00:00    0
2019-10-18 18:00:01    1
2019-10-18 18:00:02    1
2019-10-18 18:00:03    1
2019-10-18 18:00:04    2
2019-10-18 18:00:05    3
2019-10-18 18:00:06    4
2019-10-18 18:00:07    4
2019-10-18 18:00:08    4
2019-10-18 18:00:09    4
2019-10-18 18:00:10    4
2019-10-18 18:00:11    4
2019-10-18 18:00:12    4
2019-10-18 18:00:13    5
2019-10-18 18:00:14    6
2019-10-18 18:00:15    6
2019-10-18 18:00:16    6
dtype: int64
其他数字:

#Creating figure
plt.figure()
serie_to_plot.plot(figsize=(10,10))
serie_to_plot.plot(kind='bar',figsize=(10,10))

不清楚,实现结果的规则是什么明确输出背后的逻辑。输出将是只包含正波和负波的图形。你是在问如何获得这样的对还是如何绘制它们?是的,我问如何绘制。我检查了你的答案。您识别了所有的点并绘制了一个图表。重要的是数据中的变化量。看18:00:05到18:00:10之间。这里的变化是积极的。只能用一条线表示,起点为-3,终点为+5。您的代码中有4行用于此范围。它看起来应该类似于:我没有注意到它。我已经纠正了这个解决方案。请检查一下并给我的答案打分对不起!我在分数上犯了一个错误,并纠正了错误。请看这个代码:从6秒增加到10秒。但是在第11秒和第12秒的时候有下降。代码没有捕捉到它。如果你能弄明白我会很感激的。非常感谢。我不知道你的意思
#Creating figure
plt.figure()
serie_to_plot.plot(figsize=(10,10))
plt.figure()
serie_to_plot.plot(kind='bar',figsize=(10,10))
groups

2019-10-18 18:00:00    0
2019-10-18 18:00:01    1
2019-10-18 18:00:02    1
2019-10-18 18:00:03    1
2019-10-18 18:00:04    2
2019-10-18 18:00:05    3
2019-10-18 18:00:06    4
2019-10-18 18:00:07    4
2019-10-18 18:00:08    4
2019-10-18 18:00:09    4
2019-10-18 18:00:10    4
2019-10-18 18:00:11    4
2019-10-18 18:00:12    4
2019-10-18 18:00:13    5
2019-10-18 18:00:14    6
2019-10-18 18:00:15    6
2019-10-18 18:00:16    6
dtype: int64
#Creating figure
plt.figure()
serie_to_plot.plot(figsize=(10,10))
serie_to_plot.plot(kind='bar',figsize=(10,10))