From a particular dataframe I would like to create a dataframe containing the sum of the columns.
df['sum'] = df.sum(axis=1)
when excuting that line I get the warning:
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
checking that link the talk goes on about ways to use loc in multiindex dataframes. My dataframe is not multinidex.
What is the correct way to assign a column named "sum" with the addition of all the int values of the df?
This would not help to avoid the warning
x = df.sum(axis=1).copy()
df['sum'] = x