I have a dataframe like below and I would like to add all values in a row and store the sum in a new column.
var df = new dfjs.DataFrame({'col1': [1, 2, 3], 'col2': [4, 5, 6]}, ['col1', 'col2'])
So I have:
col1 col2
1 4
2 5
3 6
And I want to get:
col1 col2 col3
1 4 5
2 5 7
3 6 9
Given that dataframe contains many rows, what is the most efficient way to do that?
I figured out that I could do it like this:
And to be on the safe side with the NaN values I extended it with: