Skip to main contentSkip to solution

Which function will display the sum of each column of the DataFrame regardless of its datatype.

Solution

✅ Correct Option: 1

DataFrame.sum() returns the sum of the values in each column (axis 0 by default). It works on any datatype: numbers are added, and strings are joined (concatenated).


Option 2: add() adds another DataFrame, Series or scalar to the DataFrame element by element. It does not total a column.

Option 3: aggregate() needs a function to apply, such as aggregate('sum'). Called with no argument it does not give column sums.

Option 4: sumvalue() is not a pandas function.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question