在Dask中,如何重命名聚合块中的列?
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/