Why does Pandas display intervals with mixed parentheses and brackets?

August 5, 2026 3 answers
Asked by MellowCedar42
When creating an IntervalArray in Pandas with values such as pd.Interval(0, 1) and pd.Interval(1, 5), the output is displayed as [(0, 1], (1, 5]]. Why does each interval use a parenthesis on the left and a square bracket on the right, and what do those symbols mean?

Answers

CopperLynx18
Pandas commonly uses right-closed intervals so adjacent bins don't overlap. For example, (0, 10] and (10, 20] give each boundary value a single bin. This is especially useful with functions such as pd.cut and pd.qcut, where values are assigned to ranges.
Reply to this answer
SilverMaple63
Intervals let Pandas represent ranges and test membership without expanding every possible value. Instead of storing ranges as strings and manually parsing their endpoints, an IntervalArray can directly determine whether a value belongs to a particular interval.
Reply to this answer
QuietOrbit7
This is standard mathematical interval notation. A parenthesis means the endpoint is excluded, while a square bracket means it is included. Therefore, (0, 1] means values greater than 0 and less than or equal to 1.

MellowCedar42: That makes senseโ€”thanks for explaining it clearly. I hadn't encountered this notation before.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions