Skip to content

Commit f71d202

Browse files
Fix for issue pandas-dev#57268 - ENH: Preserve input start/end type in interval_range
1 parent 1d7aedc commit f71d202

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/core/indexes/interval.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1120,10 +1120,12 @@ def interval_range(
11201120
# error: Argument 1 to "maybe_downcast_numeric" has incompatible type
11211121
# "Union[ndarray[Any, Any], TimedeltaIndex, DatetimeIndex]";
11221122
# expected "ndarray[Any, Any]" [
1123+
dtype = start.dtype if start.dtype == end.dtype else np.dtype("int64")
11231124
breaks = maybe_downcast_numeric(
11241125
breaks, # type: ignore[arg-type]
1125-
np.dtype("int64"),
1126+
dtype,
11261127
)
1128+
return IntervalIndex.from_breaks(breaks, name=name, closed=closed, dtype=IntervalDtype(subtype=dtype, closed=closed))
11271129
else:
11281130
# delegate to the appropriate range function
11291131
if isinstance(endpoint, Timestamp):

0 commit comments

Comments
 (0)