0

How can I add a column to a dataframe with the same value

I've tried

dataframe['size']=10

or

dataframe.loc[:,'size']=10

but this gives

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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150

0 Answers0