【发布时间】:2016-08-18 03:06:17
【问题描述】:
Duplication type:
Check this column only (default)
Check other columns only
Check all columns
Use Last Value:
True - retain the last duplicate value
False - retain the first of the duplicates (default)
此规则应向数据框中添加一个新列,该列包含与任何唯一列的源列相同的列,并且任何重复列都为空。
基本代码是 df.loc[df.duplicated(),get_unique_column_name(df, "clean")] = df[get_column_name(df, column)],根据复制类型设置duplicated()的参数
请参阅上面此函数的参考:http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.duplicated.html
您应该根据duplication_type的设置来指定subset参数中的列
您应该根据上面的 use_last_value 指定 use_last_value
这是我的文件。
Jason Miller 42 4 25
Tina Ali 36 31 57
Jake Milner 24 2 62
Jason Miller 42 4 25
Jake Milner 24 2 62
Amy Cooze 73 3 70
Jason Miller 42 4 25
Jason Miller 42 4 25
Jake Milner 24 2 62
Jake Miller 42 4 25
我想通过在下面的文件中使用 pandas.in 来获得这样的结果,我选择了 2 列。
Jason Miller 42 4 25
Jake Ali 36 31 57
Jake Milner 24 2 62
Jason Miller 4 25
Jake Milner 2 62
Jake Cooze 73 3 70
Jason Miller 4 25
Jason Miller 4 25
Jake Milner 2 62
Jake Miller 4 25
请任何人回复我的问题。
【问题讨论】: