Open
Description
Is it possible to implement method DataFrame.nsorted that equivalent to df.sort_values(by=["col1", "col2"], ascending=[True, False]).head(k)
, but with time complexity O(n log k)? I know about nlargest
and nsmallest
methods but unfortunately they work only with numeric columns.
Example:
df.nsorted(k=6, by=["col1", "col2"], ascending=[True, False])