2016-07-29 29 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

相关问题