pandas 分组依据、聚集和排序索引

mwg9r5ms  于 2022-12-21  发布在  其他
关注(0)|答案(1)|浏览(90)
# I wrote this but it is geting error. can anyone explain
a =  reviews.groupby("price").agg(max).sort_index("points")

Note:- price and points are integers.

Error

对象类型DataFrame没有名为price的轴

# This is working fine but i didn't understand this?
b  = reviews.groupby('price')['points'].max().sort_index()
bn31dyow

bn31dyow1#

当你想使用聚合方法时,你必须确定哪个聚合函数应用于哪个列。第一个代码引发错误,因为你没有确定要聚合的列

相关问题