gpt4 book ai didi

python - 值错误 : Cannot index with multidimensional key

转载 作者:太空宇宙 更新时间:2023-11-03 14:46:36 29 4
gpt4 key购买 nike

我正在尝试编写一个仅使用 pandas 的简单推荐系统,但我在过滤部分遇到了问题。我想选择 RatingCounts 列大于我选择的值的所有行。这会返回一个数据框一列填充了正确的 bool 值,但我无法用这个选择索引我的数据,它给我一个值错误,如标题中所述。这是屏幕截图

enter image description here

最佳答案

selection 似乎是具有 1 列的 2D DataFrame,RatingCounts。出现错误when you pass a 2D indexerDataFrame.loc。您可以通过将一维 bool 索引器传递给 DataFrame.loc 来避免错误:

final_data.loc[selection['RatingCounts']]

关于python - 值错误 : Cannot index with multidimensional key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48734388/

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