本文主要是介绍python报错A value is trying to be set on a copy of a slice,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
加入.copy()即可避免该报错提示
原代码:
df5=df4.drop_duplicates()
print(df5.shape)df5['班型中文名称']=df5['班型名称']+'-A'
print(df5.head())
输出结果:
修改后代码:
df5=df4.drop_duplicates().copy()
print(df5.shape)df5['班型中文名称']=df5['班型名称']+'-A'
print(df5.head())
输出结果:
这篇关于python报错A value is trying to be set on a copy of a slice的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!