2
两者都返回每个组的第一行的DataFrame。在阅读API参考时,它首先说的是“计算第一组值”,但当同时查看两个输出时,我没有看到重大区别。groupby.first()和groupby.head(1)有什么区别?
我错过了什么吗?
df = pd.DataFrame({'id' : [1,1,1,2,2,3,3,3,3,4,4,5,6,6,6,7,7],
'value' : ["first","second","second","first",
"second","first","third","fourth",
"fifth","second","fifth","first",
"first","second","third","fourth","fifth"]})
非常感谢 – canyon289