Information:
System version : Windows 10 64-bit
Python version : Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
Python version : Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
先建立資料
Code:
number = [1,2,3,4,5]
sex = ['male','female','female','female','male']
df_new = pd.DataFrame()
df_new['number'] = number
df_new['sex'] = sex
print(df_new)
Result:
number sex
0 1 male
1 2 female
2 3 female
3 4 female
4 5 male
去重複
Code:
df_new.drop_duplicates(['sex'])
Result:
number sex
0 1 male
1 2 female
沒有留言:
張貼留言