我需要创建多个只具有唯一值的过滤数据帧
数据集1
Account Verified Paid Col1 Col2 Col3
1234 True True ... ... ...
1237 False True
1234 True True
4211 True True
1237 False True
312 False False
数据集2
Account Verified Paid Col1 Col2 Col3
41 True True ... ... ...
314 False False
41 True True
65 False False
多个数据帧称为dtf[i]
,其中i
从1变为2。
预期产出将是:
过滤1
Account Verified Paid
1234 True False
1237 False True
4211 True True
312 False False
过滤2
Account Verified Paid
41 True True
314 False False
65 False False
如何提取这些唯一值
如果要删除重复项,请使用以下代码:
pd.DataFrame.drop_duplicates
如果要传递所有列以定义唯一性,请改用
df.columns
编辑:
要传递列表中的所有数据帧,并且不想替换df,请使用下面的代码并说
inplace = False
(默认值)如果只想删除重复的帐号
或者,如果要删除精确的重复行:
我希望有帮助
相关问题 更多 >
编程相关推荐