pandags namedag错误:模块“pandags”没有属性“namedag”

2024-04-20 15:33:09 发布

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

我正在尝试使用pandans namedag函数,并用它撞墙了。 我收到“模块'pandags'没有属性'namedag'”错误消息。在

我在文档中使用这个例子,复制和粘贴,所以我不知道我做错了什么。有什么建议吗?在

pandas problem with NamedAgg


Tags: 模块函数文档消息属性粘贴错误建议
1条回答
网友
1楼 · 发布于 2024-04-20 15:33:09

您必须升级到pandas 0.25+Groupby aggregation with relabelingnamed aggregation

New in version 0.25.0.

To support column-specific aggregation with control over the output column names, pandas accepts the special syntax in GroupBy.agg(), known as "named aggregation", where

  • The keywords are the output column names
  • The values are tuples whose first element is the column to select and the second element is the aggregation to apply to that column. Pandas provides the pandas.NamedAgg namedtuple with the fields ['column', 'aggfunc'] to make it clearer what the arguments are. As usual, the aggregation can be a callable or a string alias.

相关问题 更多 >