Skip to content

BUG: Qcut interval not selecting the correct inclusive and exclusive limits #59355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
datatravelgit opened this issue Jul 30, 2024 · 2 comments · Fixed by #59409
Closed
2 of 3 tasks

BUG: Qcut interval not selecting the correct inclusive and exclusive limits #59355

datatravelgit opened this issue Jul 30, 2024 · 2 comments · Fixed by #59409
Assignees
Labels
Bug cut cut, qcut

Comments

@datatravelgit
Copy link

datatravelgit commented Jul 30, 2024

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

pd.__version__
'2.2.2'

cat = pd.qcut([0, 1, 2, 3], 3, precision=0)

cat
[(-1.0, 1.0], (1.0, 2.0], (2.0, 3.0], (2.0, 3.0]]
Categories (3, interval[float64, right]): [(-1.0, 1.0] < (1.0, 2.0] < (2.0, 3.0]]

while the expected output should be

cat
[(-1.0, 1.0], (-1.0, 1.0], (1.0, 2.0], (2.0, 3.0]]
Categories (3, interval[float64, right]): [(-1.0, 1.0] < (1.0, 2.0] < (2.0, 3.0]]


### Issue Description

The second element with value 1 should be allocated to the interval (-1.0, 1.0] instead of the erroneous allocation to the interval (1.0, 2.0]

### Expected Behavior

The expected behaviour should be

cat
[(-1.0, 1.0], (-1.0, 1.0], (1.0, 2.0], (2.0, 3.0]]
Categories (3, interval[float64, right]): [(-1.0, 1.0] < (1.0, 2.0] < (2.0, 3.0]]


### Installed Versions

<details>

INSTALLED VERSIONS
------------------
commit                : d9cdd2ee5a58015ef6f4d15c7226110c9aab8140
python                : 3.11.4.final.0
python-bits           : 64
OS                    : Darwin
OS-release            : 21.6.0
Version               : Darwin Kernel Version 21.6.0: Wed Apr 24 06:02:02 PDT 2024; root:xnu-8020.240.18.708.4~1/RELEASE_X86_64
machine               : x86_64
processor             : i386
byteorder             : little
LC_ALL                : None
LANG                  : None
LOCALE                : en_GB.UTF-8
pandas                : 2.2.2
numpy                 : 1.26.0
pytz                  : 2023.3.post1
dateutil              : 2.8.2
setuptools            : 68.2.0
pip                   : 23.2.1
Cython                : None
pytest                : None
hypothesis            : None
sphinx                : None
blosc                 : None
feather               : None
xlsxwriter            : None
lxml.etree            : None
html5lib              : None
pymysql               : None
psycopg2              : None
jinja2                : 3.1.2
IPython               : None
pandas_datareader     : None
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : None
bottleneck            : None
dataframe-api-compat  : None
fastparquet           : None
fsspec                : 2023.9.2
gcsfs                 : None
matplotlib            : None
numba                 : None
numexpr               : None
odfpy                 : None
openpyxl              : None
pandas_gbq            : None
pyarrow               : None
pyreadstat            : None
python-calamine       : None
pyxlsb                : None
s3fs                  : None
scipy                 : 1.11.3
sqlalchemy            : None
tables                : None
tabulate              : None
xarray                : None
xlrd                  : None
zstandard             : None
tzdata                : 2023.3
qtpy                  : None
pyqt5                 : None
</details>
@datatravelgit datatravelgit added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 30, 2024
@rob-sil
Copy link
Contributor

rob-sil commented Aug 3, 2024

take

@rhshadrach rhshadrach added cut cut, qcut and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 3, 2024
@nsyed4
Copy link

nsyed4 commented Nov 20, 2024

Hi, Is this merged and part of pandas 2.2.3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug cut cut, qcut
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants