示例DF
df = pd.DataFrame({'Animal': ['Falcon', 'Falcon', 'Falcon',
'Parrot', 'Parrot', 'Parrot'],
'Max Speed': [380., 370., 25., 24., 26., 29.]})
期望输出
2 (because the smallest difference is between 24 and 26 of Parrot)
更好(这样我可以检查)
'Parrot, 2'
我在想什么
“我需要按动物和最大速度排序,然后是一个窗口函数,但必须有更好的解决方案……”
我们可以用
diff
检查groupby
相关问题 更多 >
编程相关推荐