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?
PHP中文网2017-05-18 10:50:04
You can use the groupbys method of DataFrame to return the first and last methods of the object to obtain it