成功解决A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,co

成功解决A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,co

 

 

table of Contents

Solve the problem

Solutions


 

 

 

Solve the problem

 SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

 

 

Solutions

Reference article http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
when adding one to the list, you need to first copy the variables, you can add

a=a.copy()
a['column01']= column

 

 

Guess you like

Origin blog.csdn.net/qq_41185868/article/details/80751272