gpt4 book ai didi

python - 日期和整数之间的相关性( Pandas )?时间序列

转载 作者:太空宇宙 更新时间:2023-11-03 14:15:25 24 4
gpt4 key购买 nike

假设我的数据格式为

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

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

最佳答案

将日期时间格式更改为 numeric ,然后您可以使用 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

关于python - 日期和整数之间的相关性( Pandas )?时间序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48242555/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com