Skip to main contentSkip to solution

Consider the given DataFrame 'df4'.

NAMEPERIODICENGMATHSSCIENCE
12MEENA1406080
17REENA2603010
18TEENA3806040
20SHEENA2902070

Select the correct command to get the following output:

NAMEMEENAREENATEENASHEENA
PERIODIC8
ENG270
MATHS170
SCIENCE200

Solution

✅ Correct Option: 3

df4.sum() adds up every column. For numeric columns it gives the total (PERIODIC = 8, ENG = 270, MATHS = 170, SCIENCE = 200). For the string column NAME, "adding" means joining the strings, giving MEENAREENATEENASHEENA. This matches the output shown, which includes the NAME row.


Option 1: numeric_only=True drops the NAME column, so the first row would be missing.

Option 4: count() returns the number of non-null values in each column, not their sums.


We believe the answer could also be Option 2, since numeric_only=False includes the string column and gives the same output as the default sum(). However, NTA's final answer key (after all challenges) says Option 3.

Keyboard Shortcuts

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