Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: interval_range ignores type of start (regression from pandas 2.2.2) #58964

Open
Labels
Bug IntervalInterval data type Needs TriageIssue that has not been reviewed by a pandas team member
@michaelpradel

Description

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

import pandas as pd
import numpy as np
result = pd.interval_range(start=np.float32(0), end=2, freq=1)
print(result)

Issue Description

I'd expect the above code to produce an IntervalIndex with dtype interval[float64, right], because I'm giving a float32 as the starting value. This has been the behavior in pandas 2.2.2.

The current main branch produces the following output, though, which ignores the starting value's type:
IntervalIndex([(0, 1], (1, 2]], dtype='interval[int64, right]')

The change seems due to #57399. The PR was meant to preserve the start/end type, but actually changed the behavior so that it isn't preserved anymore in the above case.

Expected Behavior

Expected output:
IntervalIndex([(0.0, 1.0], (1.0, 2.0]], dtype='interval[float64, right]')

Installed Versions

INSTALLED VERSIONS ------------------ commit : 6dbeeb4 python : 3.10.8.final.0 python-bits : 64 OS : Linux OS-release : 6.5.0-35-generic Version : #35-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 26 11:23:57 UTC 2024 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8

pandas : 2.2.0rc0+28.g6dbeeb4009
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 63.2.0
pip : 24.0
Cython : 3.0.10
pytest : 8.2.0
hypothesis : 6.100.2
sphinx : 7.3.7
blosc : None
feather : None
xlsxwriter : 3.2.0
lxml.etree : 5.2.1
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.9
jinja2 : 3.1.3
IPython : 8.24.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.8
fastparquet : 202420
fsspec : 2024年3月1日
gcsfs : 2024年3月1日
matplotlib : 3.8.4
numba : 0.59.1
numexpr : 2.10.0
odfpy : None
openpyxl : 3.1.2
pyarrow : 16.0.0
pyreadstat : 1.2.7
python-calamine : None
pyxlsb : 1.0.10
s3fs : 2024年3月1日
scipy : 1.13.0
sqlalchemy : 2.0.29
tables : 3.9.2
tabulate : 0.9.0
xarray : 202430
xlrd : 2.0.1
zstandard : 0.22.0
tzdata : 2024.1
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug IntervalInterval data type Needs TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /