gpt4 book ai didi

python - 类型错误 : '_AtIndexer' object is not callable in pandas

转载 作者:行者123 更新时间:2023-12-05 01:07:52 34 4
gpt4 key购买 nike

我有一个名为 dfDataFrame 对象,我想生成一个格式正确的日期列表。 (datetime 模块已正确导入)

我写道:

dates = [datetime.date(df.at(index, "year"), df.at(index, "month"), df.at(index, "day")) for index in df.index]

在标题中给出了错误。

如果有帮助,这就是 df.head() 的值:

   year  month  day  smoothed   trend
0 2011 1 1 391.26 389.76
1 2011 1 2 391.29 389.77
2 2011 1 3 391.33 389.78
3 2011 1 4 391.36 389.78
4 2011 1 5 391.39 389.79

(这对我来说是新的,所以我可能误解了文档)

最佳答案

df.at 不是callable,而是一个支持索引的property。所以将括号改为方括号:

df.at[index, "year"]

([ 和类似的关闭。

关于python - 类型错误 : '_AtIndexer' object is not callable in pandas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66820806/

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