Dask:如何在“分组依据”-“ agg”块中重命名列?

时间:2019-11-13 14:57:25

标签: pandas dask

在Dask中,如何重命名聚合块中的列?

sample_file:

id, class, student
1, 1grade, john
1, 1grade, sam
1, 1grade, harry

当前代码:

df_src = dd.read_csv('dask_metrics_agg/sample_file.csv')

grp_by_cols = ['id', 'class']

df_src.groupby(grp_by_cols).agg({'student': 'count'}).compute().to_csv('output.csv')

期望如下所示:

.agg(
{
'student': 'count' as 'student_count'
}
)

注意: 可以在下面的链接中提到的熊猫中做到这一点,但无法通过dask来解决: https://www.shanelynn.ie/summarising-aggregation-and-grouping-data-in-python-pandas/

0 个答案:

没有答案