Pandas报错A value is trying to be set on a copy of a slice from a DataFrame.

Pandas添加列时报错A value is trying to be set on a copy of a slice from a DataFrame.

df_duplicated['buttonSalary'] = df_duplicated['salary'].apply(deal_salary,args=('up',))

大概意思是在DataFrame复制切片上设置值导致这个报错,类似word副本不允许编辑。请添加图片描述
解决方法:
用pd.DataFrame()方法格式化下这个副本数据

df_duplicated = pd.DataFrame(df_duplicated)
df_duplicated['buttonSalary'] = df_duplicated['salary'].apply(deal_salary,args=('up',))

你可能感兴趣的:(pandas,python,数据挖掘,pandas)