-1
Title Netquantity Bases Chambers
x          2              4
y                 5       

To get the total of bases chambers, I've used

concat_list.loc['Total'] = concat_list[['Bases','Chambers']].sum()

However, the output was

Title Netquantity Bases Chambers

x          2              4
y                 5        
Total    NaN    NaN     NaN

Could you help me to debug this issue? Some of the numbers are empty. I tried to

concat_list = concat_list.fillna(0)

But still didn't work.

ThePyGuy
  • 17,779
  • 5
  • 18
  • 45

1 Answers1

0

Here is problem there are values mixed strings with numeric or all strings, first tray convert to floats:

concat_list.loc['Total'] = concat_list[['Bases','Chambers']].astype(float).sum()

If not working, try replace not parseable values to missing values by to_numeric per all columns, so use DataFrame.apply:

concat_list.loc['Total'] = concat_list[['Bases','Chambers']].apply(pd.to_numeric, errors='coerce').sum()
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252