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