Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas Can not sum dataframe

I have dataframe like this.

                                  E   F                                 
    ID    A     B       C     D   E   F
    0    0     ABC    AAA    BCD  1   -
    1    1     ABC    AAA    BCD  4   -  
    2    2     ABC    AAA    BCD  6   -

I print type of dataframe by print(type(df['E'])) it show output like this.

<class 'pandas.core.series.Series'>

I try to sum total value in column E but it show output like this

E146

How to sum data in dataframe column? The correct value should be 11 (1+4+6).

like image 456
user572575 Avatar asked Jan 26 '26 22:01

user572575


1 Answers

Use:

print(df['E'].iloc[1:].astype(int).sum())
like image 173
U12-Forward Avatar answered Jan 29 '26 13:01

U12-Forward



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!