简体   繁体   中英

ValueError: could not convert string to float: '01-01-20 0:15'

Below, there is a sample data set I am working on, I store average values every 30 min.

|Slot              |    value|
|01-01-2018 00:30  |   78.3  |
|01-01-2018 01:00  |   74.5  |
|01-01-2018 01:30  |   79.2  |
|01-01-2018 02:00  |   78.7  |
|01-01-2018 02:30  |   77.3  |
|01-01-2018 03:30  |   76.4  |

When I try to plot auto-correlation function (ACF) graph for this data set, I get error message:

ValueError: could not convert string to float: '01-01-20 0:15'

Here is my code

from statsmodels.graphics.tsaplots import plot_acf
plot_acf(freq)

The plot_acf function takes in values, and the lag needs to be defined in a separate argument.

plot_acf(df['value'])

If the lag matters to you (I don't think it does since you already have regular 30 min intervals) you can define lags.

lags = [0, 30, 60, 90...]
plot_acf(df['value'], lags=lags)

https://www.statsmodels.org/stable/generated/statsmodels.graphics.tsaplots.plot_acf.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM