np.argmax公司不返回正确的索引

2024-10-17 12:21:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我用过np.argmax公司搜索此数组的最大值的索引

enter image description here

它返回了720。应该是721。我试着用谷歌搜索这个问题,但还没有找到解决办法。在

这是我的代码:

import pandas as pd
import numpy as np
import matplotlib.pylab as plt
from matplotlib.pylab import rcParams
from statsmodels.tsa.stattools import acf, pacf

dir='C:\\Users\\DELL\\Google Drive\\JVN couse materials\\Projects\\Practice projects\\Time series project\\energydata_complete.csv'
rawdata=pd.read_csv(dir, index_col='date')
timeseries=pd.DataFrame(rawdata['Appliances'])
timeseries.index=pd.to_datetime(timeseries.index)
timeseries['Log scale']=np.log10(timeseries['Appliances'])
lag_pacf = pacf(timeseries.loc['2016-01-12':'2016-01-21','Log scale'], nlags=1439, method='ols')
highest_pacf_lag=np.argmax(lag_pacf[1:]) ###this is where the problem happens

Tags: csvfromimportindexmatplotlibasdirnp