1

I am trying to sum all values of a column. My df looks like this:

    Datum Uhrzeit Deutschland/Luxemburg[Euro/MWh]
0   06.06.2020   00:00                            7.69
1   06.06.2020   01:00                            1.46
2   06.06.2020   02:00                           -0.09
3   06.06.2020   03:00                            0.03
4   06.06.2020   04:00                            1.44

I have tried with a for loop:

for i in df["Deutschland/Luxemburg[Euro/MWh]"]:
    print(df["Deutschland/Luxemburg[Euro/MWh]"][i])

How could I do it right?

some_programmer
  • 3,268
  • 4
  • 24
  • 59

1 Answers1

0

you can use the sum function of pandas

df.sum()

I guess you want the sum of the last column, so you could do:

df['Deutschland/Luxemburg[Euro/MWh]'].sum()
SevenOfNine
  • 630
  • 1
  • 6
  • 25