Skip to main contentSkip to solution

Given the following series 'ser1':

069
180
220
350
4100
570

State the output of the following command:

print(ser1>=70)

Solution

✅ Correct Option: 2

Comparing a pandas Series with a number gives a Series of Boolean values, one for each element, with the same index. Nothing is filtered out. Here the values are 69, 80, 20, 50, 100 and 70, and the test is ≥70\ge 70:

IndexValue≥70\ge 70
069False
180True
220False
350False
4100True
570True

Option 2 shows this Boolean Series with all six rows, using F and T as shorthand for False and True. Real pandas output prints the full words and ends with dtype: bool.


Options 1 and 4: these show the filtered values, which you get from ser1[ser1>=70]. The bare comparison does not filter.

Option 3: it keeps only the True rows, which is wrong because the comparison returns every index, including the False ones.

Keyboard Shortcuts

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