I have dataframe where I create new column as a sum of other columns:
df['newcol'] = df['col1'] + df['col2'] + df['col3']
but this solution doesn't work properly, because the sum in the file is much bigger than in dataframe.
Instead of code above I used df.assign as below and it works perfectly
df = df.assign(newcol=[['col1','col2','col3']].sum(axis=1))
Are there any differences in both methods? Why the second one works correctly? Do you have any idea why this works different? Unfortunately I cannot show you the original file.