日期和整数之间的相关(熊猫)?时间序列

时间:2018-01-13 17:44:57

标签: python pandas statistics time-series

假设我的数据是

的形式
date       | price
2017-09-09 | 13000
2017-09-08 | 20000
2017-09-07 | 15000
2017-09-06 | 13000
2017-09-05 | 15000

如何找到价格和时间之间的相关性? df.corr()忽略日期列。

1 个答案:

答案 0 :(得分:0)

将日期时间格式更改为数字,然后您可以使用corr

df.date=pd.to_datetime(df.date)
df.date=pd.to_numeric(df.date)
df.corr()
Out[306]: 
           date     price
date   1.000000  0.165647
price  0.165647  1.000000