简体   繁体   English

如何按降序对 dask dataframe 进行排序?

[英]How to sort a dask dataframe in descending order?

Apparently, the ascending keyword does not exist in dask, which is funny because dask is designed to resemble pandas.显然,dask 中不存在升序关键字,这很有趣,因为 dask 的设计类似于 pandas。 This does not work:这不起作用:

res = ddf.groupby(['An important column']).mean().sort_values('Score', ascending=False).compute()

What would be the best way to do that descending sorting with dask?用 dask 进行降序排序的最佳方法是什么?

NotImplementedError: The ascending= keyword is not supported NotImplementedError:不支持升序 = 关键字

dask 2021.4.0黎明2021.4.0

If the delayed result is very small (fits in worker/client memory) and has a task graph that does not involve a lot of data shuffling, then it's usually OK to run .compute first (to turn the delayed value into pandas df) and then run the missing/not implemented function.如果延迟结果非常小(适合工作/客户端内存)并且具有不涉及大量数据混洗的任务图,那么通常可以先运行.compute (将延迟值转换为 pandas df)和然后运行缺少/未实现的 function。

For example, this could be done as follows:例如,这可以按如下方式完成:

res = ddf.groupby(['An important column']).mean().compute().sort_values('Score', ascending=False)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM