gpt4 book ai didi

python - Pandas 自相关函数错误 : 'DataFrame' object has no attribute 'autocorr'

转载 作者:太空宇宙 更新时间:2023-11-04 00:34:56 25 4
gpt4 key购买 nike

我想在 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'

最佳答案

some_dataframe["col_name"] 返回一个 Seriessome_dataframe[["col_name"]] 返回一个 DataFrameautocorr is a Series function .

关于python - Pandas 自相关函数错误 : 'DataFrame' object has no attribute 'autocorr' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44442358/

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