df:
-----------+
| word|
+-----------+
| 1609|
| |
| the|
| sonnets|
| |
| by|
| william|
|shakespeare|
| |
| fg|
这是我的数据框。如何使用“where”子句删除空行(删除包含“”的行)。
code:
df.where(trim(df.word) == "").show()
output:
----+
|word|
+----+
| |
| |
| |
| |
| |
| |
| |
| |
| |
感谢任何帮助。
最佳答案
您可以修剪并检查结果是否为空:
>>> from pyspark.sql.functions import trim
>>> df.where(trim(df.word) != "")
关于apache-spark - Apache Spark 中的“哪里”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38378315/