【问题标题】:Correllation (pandas) between date and integer? timeseries日期和整数之间的相关性(熊猫)?时间序列
【发布时间】:2018-06-22 21:03:58
【问题描述】:

假设我的数据格式为

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

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

【问题讨论】:

    标签: python pandas statistics time-series


    【解决方案1】:

    将日期时间格式改为数字,则可以使用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
    

    【讨论】:

    • 非常感谢,没想到这么简单!
    • @Zeruno yw~ 快乐编码
    猜你喜欢
    • 2020-06-23
    • 2013-06-05
    • 2020-10-19
    • 2014-01-01
    • 2021-05-08
    • 2016-07-05
    • 2022-10-17
    • 2020-10-02
    相关资源
    最近更新 更多