# 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()
1条答案
按热度按时间bn31dyow1#
当你想使用聚合方法时,你必须确定哪个聚合函数应用于哪个列。第一个代码引发错误,因为你没有确定要聚合的列