PySpark 2.0 DataFrame的大小或形状 [英] PySpark 2.0 The size or shape of a DataFrame

查看:410
本文介绍了PySpark 2.0 DataFrame的大小或形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出PySpark中DataFrame的大小/形状。我看不到单个函数可以做到这一点。

I am trying to find out the size/shape of a DataFrame in PySpark. I do not see a single function that can do this.

在Python中,我可以做到

In Python I can do

data.shape()

PySpark中是否有类似的功能。这是我目前的解决方案,但我正在寻找一个元素

Is there a similar function in PySpark. This is my current solution, but I am looking for an element one

row_number = data.count()
column_number = len(data.dtypes)

列数的计算并不理想...

The computation of the number of columns is not ideal...

推荐答案

您可以通过以下方式获得其形状

You can get its shape with:

print((df.count(), len(df.columns)))

这篇关于PySpark 2.0 DataFrame的大小或形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆