Skip to content
Advertisement

sum of row in the same columns in pandas

i have a dataframe something like this

JavaScript

how do i get the sum of values between the same column in a new column in a dataframe for example:

JavaScript

i want a new column with the sum of d1[i] + d1[i+1] .i know .sum() in pandas but i cant do sum between the same column

Advertisement

Answer

Your question is not fully clear to me, but I think what you mean to do is:

JavaScript

Now you have to decide what you want to happen for the last element of the series.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement