如何获得独特的价值

时间:2018-08-04 03:04:00

标签: pandas

我有这个df:

 data = pd.read_csv('attacks.csv', encoding="latin-1")
 new_data = data.loc[:,'Name':'Investigator or Source']
 new_data.head(5)

 Name   Sex     Age     Injury  Fatal (Y/N)     Time    Species     Investigator or Source
 0  Julie Wolfe     F   57  No injury to occupant, outrigger canoe and  pad...  N   18h00   White shark     R. Collier, GSAF
 1  Adyson McNeely  F   11  Minor injury to left thigh  N   14h00 -15h00    NaN     K.McMurray, TrackingSharks.com
 2  John Denges     M   48  Injury to left lower leg from surfboard skeg    N   07h45   NaN     K.McMurray, TrackingSharks.com
 3  male    M   NaN     Minor injury to lower leg   N   NaN     2 m shark   B. Myatt, GSAF
 4  Gustavo Ramos   M   NaN     Lacerations to leg & hand shark PROVOKED INCIDENT   N   NaN     Tiger shark, 3m     A .Kipper

如何获取``种类''类别的唯一值?  我正在尝试:

 new_data["Species"].unique()

但这不起作用。

谢谢!

1 个答案:

答案 0 :(得分:0)

您也可以尝试:

uniqueSpecies = set(new_data["Species"])

以防您想丢掉NaN

uniqueSpecies = set(new_data["Species"].dropna())
相关问题