2016-07-29 30 views
5

我明白,這只是一個很簡單的問題,最有可能被某個回答,但作爲一個初學者我還是不明白這一點,我期待你的啓發,謝謝你在前進:如何使用pyspark獲取數據幀中的不同行?

我有一個臨時據幀:

+----------------------------+---+ 
|host      |day| 
+----------------------------+---+ 
|in24.inetnebr.com   |1 | 
|uplherc.upl.com    |1 | 
|uplherc.upl.com    |1 | 
|uplherc.upl.com    |1 | 
|uplherc.upl.com    |1 | 
|ix-esc-ca2-07.ix.netcom.com |1 | 
|uplherc.upl.com    |1 | 

我需要的是去除所有多餘的物品在主柱,換句話說,我需要得到最終的結果不同,如:

+----------------------------+---+ 
|host      |day| 
+----------------------------+---+ 
|in24.inetnebr.com   |1 | 
|uplherc.upl.com    |1 | 
|ix-esc-ca2-07.ix.netcom.com |1 | 
|uplherc.upl.com    |1 | 

回答

7

如果DF是你的數據框的名稱,有兩種方法可以得到唯一的行:

df2 = df.distinct() 

df2 = df.drop_duplicates() 
+0

感謝。這很簡單 – mdivk

相關問題