2016-07-26 133 views
0

我有一些数据在熊猫系列,当我键入站连接点

mydata.head() 

我得到:

     BPM 
timestamp 
2015-04-07 02:24:00 96.0 
2015-04-07 02:24:00 96.0 
2015-04-07 02:24:00 95.0 
2015-04-07 02:24:00 95.0 
2015-04-07 02:24:00 95.0 

此外,使用

mydata.info() 

我得到:

<class 'pandas.core.frame.DataFrame'> 
DatetimeIndex: 33596 entries, 2015-04-07 02:24:00 to 2015-07-15 14:23:50 
Data columns (total 1 columns): 
BPM 33596 non-null float64 
dtypes: float64(1) 
memory usage: 524.9 KB 

当我去使用

import matplotlib.pyplot as pyplot 

fig, ax = pyplot.subplots() 
ax.plot(mydata) 

time series plot with points connected

我只是得到一个完整的一塌糊涂绘制,它就像它的加入很多分在一起,不应该连在一起的。

我该如何分类显示为适当的时间序列图?

+0

你试过mydata.plot(“”) – nico

+1

按日期排序的数据? – joris

回答

1

只要告诉matplotlib画出标记,而不是线。例如,

import matplotlib.pyplot as pyplot 

fig, ax = pyplot.subplots() 
ax.plot(my data, '+') 

如果你喜欢别的标记,你可以改变它(see this link)。

您也可以直接从pandas情节:

mydata.plot('+') 

如果你真的想要的线,你需要绘制它之前对数据进行排序。