BUG: Using pd.cut with IntervalIndex containing Timedeltas returns only NaN #47171
Closed
2 of 3 tasks
Labels
Bug
cut
cut, qcut
Duplicate Report
Duplicate issue or pull request
Regression
Functionality that used to work in a prior pandas version
Milestone
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
Issue Description
Using
pd.cut
when the bins are anIntervalIndex
that containsTimedelta
returns onlyNaN
. Output from the example isI believe the problem might be that the data,
s
in the example, is converted to a numeric data type but the bins are not.Expected Behavior
The data should be binned according to the intervals in the IntervalIndex. Output from the example should be
Installed Versions
Running
pd.show_versions()
fails onassert '_distutils' in core.__file__, core.__file__
in.../_distutils_hack/__init__.py:59
which is quite confusing but I was able to get around this by setting the environment variableSETUPTOOLS_USE_DISTUTILS=stdlib
.INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.10.4.final.0
python-bits : 64
OS : Darwin
OS-release : 21.5.0
Version : Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 61.2.0
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.1
IPython : 8.2.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : 0.8.1
fsspec : 2022.3.0
gcsfs : None
markupsafe : 2.1.1
matplotlib : 3.5.1
numba : None
numexpr : 2.8.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 7.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
snappy : None
sqlalchemy : 1.4.35
tables : 3.7.0
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: