Correllation (pandas) between date and integer? timeseries

Suppose my data is in the form of

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

How do I find the correlation between price and time? df.corr() ignores the date column.

1 answer

  • answered 2018-01-13 17:44 Wen

    Change date time format to numeric , then you can use 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