2016-07-14 73 views
0
df: 

-----------+ 
|  word| 
+-----------+ 
|  1609| 
|   | 
|  the| 
| sonnets| 
|   | 
|   by| 
| william| 
|shakespeare| 
|   | 
|   fg| 

這是我的數據框。如何使用'where'子句刪除空行(刪除包含''的行)。'where'in apache spark

code: 

df.where(trim(df.word) == "").show() 

output: 

----+ 
|word| 
+----+ 
| | 
| | 
| | 
| | 
| | 
| | 
| | 
| | 
| | 

任何幫助表示讚賞。

回答

1

您可以修剪和檢查,如果結果爲空:

>>> from pyspark.sql.functions import trim 
>>> df.where(trim(df.word) != "") 
+0

感謝的時間。該解決方案不起作用。它使數據框中的所有行都爲空。我會更新問題部分以顯示結果。 –

+0

對不起,操作員輸入錯誤。 – 2016-07-14 15:47:11

+0

感謝它的工作。 –