假设我有这个数据帧:
df = pd.DataFrame({
'price': [2, 13, 24, 15, 11, 44],
'category': ["shirts", "pants", "shirts", "tops", "hat", "tops"],
})
price category
0 2 shirts
1 13 pants
2 24 shirts
3 15 tops
4 11 hat
5 44 tops
我希望以如下方式对值进行排序:
最后一个数据帧如下所示:
price category
0 44 tops
1 15 tops
2 24 shirts
3 24 shirts
4 13 pants
5 11 hat
我在数据帧应用中使用了get_组来获取类别的最大价格
输出
您可以使用^{} 和^{} :
输出
我不太喜欢一行程序,所以我的解决方案是:
相关问题 更多 >
编程相关推荐