【发布时间】:2023-03-21 20:35:02
【问题描述】:
运行一个简单的例子 -
dept = [("Finance",10),("Marketing",None),("Sales",30),("IT",40)]
deptColumns = ["dept_name","dept_id"]
rdd = sc.parallelize(dept)
df = rdd.toDF(deptColumns)
df.show(truncate=False)
print('count the dept_id, should be 3')
print('count: ' + str(df.select(F.col("dept_id")).count()))
我们得到以下输出 -
+---------+-------+
|dept_name|dept_id|
+---------+-------+
|Finance |10 |
|Marketing|null |
|Sales |30 |
|IT |40 |
+---------+-------+
count the dept_id, should be 3
count: 4
我在数据块上运行,这是我的堆栈 - Spark 3.0.1 Scala 2.12,DBR 7.3 LTS
感谢您的帮助!!
【问题讨论】:
标签: pyspark