Skip to content
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ Interval
- :meth:`Index.is_monotonic_decreasing`, :meth:`Index.is_monotonic_increasing`, and :meth:`Index.is_unique` could incorrectly be ``False`` for an ``Index`` created from a slice of another ``Index``. (:issue:`57911`)
- Bug in :class:`Index`, :class:`Series`, :class:`DataFrame` constructors when given a sequence of :class:`Interval` subclass objects casting them to :class:`Interval` (:issue:`46945`)
- Bug in :func:`interval_range` where start and end numeric types were always cast to 64 bit (:issue:`57268`)
- Bug in :func:`pandas.interval_range` incorrectly inferring ``int64`` dtype when ``np.float32`` and ``int`` are used for ``start`` and ``freq`` (:issue:`58964`)
- Bug in :meth:`IntervalIndex.get_indexer` and :meth:`IntervalIndex.drop` when one of the sides of the index is non-unique (:issue:`52245`)
- Construction of :class:`IntervalArray` and :class:`IntervalIndex` from arrays with mismatched signed/unsigned integer dtypes (e.g., ``int64`` and ``uint64``) now raises a :exc:`TypeError` instead of proceeding silently. (:issue:`55715`)

Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,9 +1420,9 @@ def interval_range(
dtype: np.dtype = np.dtype("int64")
if com.all_not_none(start, end, freq):
if (
isinstance(start, (float, np.float16))
or isinstance(end, (float, np.float16))
or isinstance(freq, (float, np.float16))
isinstance(start, (float, np.floating))
or isinstance(end, (float, np.floating))
or isinstance(freq, (float, np.floating))
):
dtype = np.dtype("float64")
elif (
Expand Down
12 changes: 11 additions & 1 deletion pandas/tests/indexes/interval/test_interval_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_float_subtype(self, start, end, freq):
[
(np.int8(1), np.int8(10), np.dtype("int8")),
(np.int8(1), np.float16(10), np.dtype("float64")),
(np.float32(1), np.float32(10), np.dtype("float32")),
(np.float32(1), np.float32(10), np.dtype("float64")),
(1, 10, np.dtype("int64")),
(1, 10.0, np.dtype("float64")),
],
Expand Down Expand Up @@ -380,3 +380,13 @@ def test_float_freq(self):
result = interval_range(0, 1, freq=0.6)
expected = IntervalIndex.from_breaks([0, 0.6])
tm.assert_index_equal(result, expected)

def test_interval_range_float32_start_int_freq(self):
# GH 58964
from pandas.testing import assert_index_equal

result = interval_range(start=np.float32(0), end=2, freq=1)
expected = IntervalIndex.from_tuples(
[(0.0, 1.0), (1.0, 2.0)], dtype="interval[float64, right]"
)
assert_index_equal(result, expected)
Loading