python - pandas How to "quickly" get the first and last rows of tens of millions of data groups?
大家讲道理
大家讲道理 2017-05-18 10:48:04
0
1
1037

I hope to get the first and last rows of each group after pandas grouping. The current method is to traverse the group for name, group in xxx: then group.iloc[0] group.iloc[-1], but this Traversing tens of millions of data is very slow. Is there any fast method?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
洪涛

You can use the groupbys method of DataFrame to return the first and last methods of the object to obtain it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template