1. Home
  2. Data Science
  3. Pandas
  4. pd.cut is called with bins 0, 10 and 20 and right=False…

Added 30 Nov -0001

pd.cut is called with bins 0, 10 and 20 and right=False. Which interval does the value 10 fall into?

  1. The interval from 0 up to 10, because right=False moves the closed edge
  2. The interval from 10 up to 20, because right=False makes bins left-closed Correct answer
  3. The interval from 0 up to 10, since the default includes the right edge
  4. A missing category, because the value 10 sits exactly on a bin boundary point

Correct answer

B. The interval from 10 up to 20, because right=False makes bins left-closed

15 views

MCQSEXAM

Explanation

cut is right-closed by default, so bins look like (0, 10], and right=False flips that to [0, 10), placing the boundary value 10 in the second interval. include_lowest=True is needed to capture the very lowest value, which the open left edge normally excludes. Unlike qcut, cut uses fixed numeric edges rather than equal-count quantiles.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Pandas MCQs

Practise all Pandas MCQs

Similar MCQs