首页 > 解决方案 > 我应该如何获得 dask 数据框的形状?

问题描述

执行 .shape 给了我以下错误。

AttributeError:“DataFrame”对象没有属性“shape”

我应该如何获得形状?

标签: pythondask

解决方案


可以直接获取列数

len(df.columns)  # this is fast

您也可以在数据帧本身上调用 len,但请注意这会触发计算。

len(df)  # this requires a full scan of the data

Dask.dataframe 不知道您的数据中有多少条记录,而无需先阅读所有记录。


推荐阅读