from numpy import nan from pandas import DataFrame flag=[] k=21 flag.append(k) print(flag[0]) print(len(flag)) a=nan if a is nan: a='KK' else: a=a+','+'KK' print(a) b='bd' if b=='bd': print(b) df=DataFrame({'A':[1,2,1],'B':[1,6,2]}) print(df['A'].isin([2]) ) print(df[df['A'].isin([2])] ) print(df) df=df.drop_duplicates(subset=['A'],keep='last') print(df)
#结果:
21 1 KK bd 0 False 1 True 2 False Name: A, dtype: bool A B 1 2 6 A B 0 1 1 1 2 6 2 1 2 A B 1 2 6 2 1 2
pandas去重、缺失
最新推荐文章于 2024-07-17 10:37:21 发布