Consider the given DataFrame 'df4'.
NAME PERIODIC ENG MATHS SCIENCE 12 MEENA 1 40 60 80 17 REENA 2 60 30 10 18 TEENA 3 80 60 40 20 SHEENA 2 90 20 70
Select the correct command to get the following output:
NAME MEENAREENATEENASHEENA PERIODIC 8 ENG 270 MATHS 170 SCIENCE 200
Consider the given DataFrame 'df4'.
| NAME | PERIODIC | ENG | MATHS | SCIENCE | |
|---|---|---|---|---|---|
| 12 | MEENA | 1 | 40 | 60 | 80 |
| 17 | REENA | 2 | 60 | 30 | 10 |
| 18 | TEENA | 3 | 80 | 60 | 40 |
| 20 | SHEENA | 2 | 90 | 20 | 70 |
Select the correct command to get the following output:
| NAME | MEENAREENATEENASHEENA |
|---|---|
| PERIODIC | 8 |
| ENG | 270 |
| MATHS | 170 |
| SCIENCE | 200 |
Solution
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.
Related questions:
2025: 3 June Shift 2
2025: 15 May Shift 2
2025: 27 May Shift 2