0
点赞
收藏
分享

微信扫一扫

pandas drop_duplicates()函数 去重

流计算Alink 2022-04-21 阅读 49
python

 

import numpy as np
from pandas import DataFrame
test = [['a','a'],
        ['a','b'],
        ['a','a'],
        ['c','b']
        ]
test = DataFrame(np.array(test))
test1 = test.drop_duplicates(keep='first')#删除重复项并保留第一次出现的额重复项
test2 = test.drop_duplicates([0],keep='first')#在第0列删除重复项
test2 = test.drop_duplicates([1],keep='first')#在第一列删除重复项
print(test)
print(test1)
print(test2)
   0  1
0  a  a
1  a  b
2  a  a
3  c  b

   0  1
0  a  a
1  a  b
3  c  b

   0  1
0  a  a
1  a  b

 

举报

相关推荐

0 条评论