Skip to content

Commit ea22074

Browse files
committed
fix interval
1 parent d48f7bb commit ea22074

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pandas/core/arrays/interval.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
from pandas.errors import IntCastingNaNError
4747
from pandas.util._decorators import Appender
4848

49-
from pandas.core.dtypes.cast import LossySetitemError
49+
from pandas.core.dtypes.cast import (
50+
LossySetitemError,
51+
maybe_upcast_numeric_to_64bit,
52+
)
5053
from pandas.core.dtypes.common import (
5154
is_categorical_dtype,
5255
is_dtype_equal,
@@ -304,7 +307,10 @@ def _ensure_simple_new_inputs(
304307
from pandas.core.indexes.base import ensure_index
305308

306309
left = ensure_index(left, copy=copy)
310+
left = maybe_upcast_numeric_to_64bit(left)
311+
307312
right = ensure_index(right, copy=copy)
313+
right = maybe_upcast_numeric_to_64bit(right)
308314

309315
if closed is None and isinstance(dtype, IntervalDtype):
310316
closed = dtype.closed

pandas/tests/indexes/interval/test_interval.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,9 @@ def test_maybe_convert_i8_numeric(self, make_key, any_real_numpy_dtype):
427427
key = make_key(breaks)
428428

429429
result = index._maybe_convert_i8(key)
430-
expected = Index(key)
430+
kind = breaks.dtype.kind
431+
expected_dtype = {"i": np.int64, "u": np.uint64, "f": np.float64}[kind]
432+
expected = Index(key, dtype=expected_dtype)
431433
tm.assert_index_equal(result, expected)
432434

433435
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)