You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to select the first 2 entries of each group ordered by a specific column. I can easily get these values if I only want to keep the column used for the ordering (see code below) but it gets way less efficient and not as clear when I want to keep all the columns of the DataFrame.
The text was updated successfully, but these errors were encountered:
mcarbajo
changed the title
ENH: Create a nlargest and nsmallest methods for pandas.core.groupby.DataFrame objects
ENH: Create a nlargest and nsmallest methods for pandas.core.groupby.DataFrameGroupBy objects
Nov 29, 2018
Might be overlooking it but what is wrong with using apply? We have very few groupby functions outside of apply that either don't maintain the shape of the caller or reduce to a scalar per group, so this would be somewhat of an anomaly. As such -1 as I don't see the value add against using apply
Code Sample, a copy-pastable example if possible
Current method
Desired method
Problem description
I want to select the first 2 entries of each group ordered by a specific column. I can easily get these values if I only want to keep the column used for the ordering (see code below) but it gets way less efficient and not as clear when I want to keep all the columns of the DataFrame.
The text was updated successfully, but these errors were encountered: