我想在 Google 趋势历史数据中找到自相关。非官方 API 使用 Pandas Dataframes,我决定为其使用其内置的自相关函数,代码如下:
from pytrends.request import TrendReq
z = ["animales"]
google_username = "xxx@gmail.com"
google_password = "xxxxxxxxx"
path = ""
pytrend = TrendReq(google_username, google_password, custom_useragent='')
pytrend.build_payload(kw_list=z, timeframe='today 5-y', geo='MX')
interest_over_time_df = pytrend.interest_over_time()
print(interest_over_time_df[z].autocorr(lag=1))
这以前有效,但我不确定我更改了什么,我的代码抛出以下错误:
Traceback (most recent call last):
File "C:/Users/Rafael/PycharmProjects/untitled/test.py", line 19, in <module>
print(interest_over_time_df[z].autocorr(lag=1))
File "C:\Users\Rafael\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandas\core\generic.py", line 2744, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'autocorr'
我是一名优秀的程序员,十分优秀!