A value is trying to be set on a copy of a slice from a DataFrame 解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_34233802/article/details/79867458

1、当需要对dataFrame迭代赋值时,会产生上述错误,可采用下列方式

for i in duplicates.index:
    duplicates.at[i,'columsname'] = 'abc'

2、字符格式化问题

对某一列format
a['lon'].astype(float).map('{:.1f}'.format)
保存时format 保留三位
all_mix.to_csv('../new_list/all_final.csv',float_format='%.6g')

猜你喜欢

转载自blog.csdn.net/sinat_34233802/article/details/79867458