2

Yes I know there are many questions like this.

This question is about a specific behavior:

import pandas as pd
x = [
    0,0,0,0,
    1,1,1,
    2,2,2,
    3,3,3
]

print pd.qcut(x, 4)
# ValueError: Bin edges must be unique: array([0, 0, 1, 2, 3]).

I had assumed qcut would produce edges (0,1], (1,2], (2,3], (3, 3), which would bin the items how I visually organized them. This obviously has to something to do with left-inclusivity and right-exclusivity but intuitively it feels like x can be discretized into four parts.

Does anyone have a sense of what I'm missing?

Nolan Conaway
  • 2,639
  • 1
  • 26
  • 42

0 Answers0