arkouda
arkouda copied to clipboard
Add support for ascending list in `df.sort_values`
Add support for something like this:
df.sort_values(by=['col_a', 'col_b'], ascending=[True, False])
Example of a workaround provided for user
>>> pd_df = pd.DataFrame({'col_a': (np.arange(5) % 2 == 0).astype(int), 'col_b': np.arange(5,0,-1), 'col_c': np.arange(5)})
>>> ak_df = ak.DataFrame(pd_df)
>>> def list_sort_values_workaround(df, col_names, order_list):
return df[ak.coargsort([df[c_name] if ascend else -df[c_name] for c_name, ascend in zip(col_names, order_list)])]
I think we basically just add an if isinstance(ascending, list)
then do a size check. If those are both fine then return the line from the workaround
it's also worth noting this only applies to numeric values. Right now we don't guarantee sorting on strings, categoricals anyway, only ordering