我有一个包含多列的表(df):列1、列2、列3等等。
| 列1|列2|第3栏|- -|科隆|
| - ------| - ------| - ------| - ------| - ------|
| 1个|美国广播公司|1个||奎|
| 1个|某某||||
| 第二章||三个|||
| 三个|美国广播公司|六个||奎|
我希望我的最终表格(df)有以下列:
attribute_name: contains the name of columns from previous table
count: contains total count of the table
distinct_count: contains distinct count of each column from previous table
null_count: contains count of null values of each column from previous table
最终表格应如下所示:
| 属性名称|计数|非重复计数|空计数|
| - ------| - ------| - ------| - ------|
| 列1|四个|三个|无|
| 列2|四个|第二章|1个|
| 第3栏|四个|三个|1个|
| 科隆|四个|1个|第二章|
有人能帮助我如何在pyspark中实现这一点吗?
1条答案
按热度按时间ubby3x7f1#
我没有测试它或检查它是否正确,但像这样的东西应该工作: