Skip to content

Commit

Permalink
Fix issue: ENH: Preserve input start/end type in interval_range panda…
Browse files Browse the repository at this point in the history
  • Loading branch information
VISWESWARAN1998 committed Feb 13, 2024
1 parent 9d4bbfc commit b5aa727
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,10 +1120,12 @@ def interval_range(
# error: Argument 1 to "maybe_downcast_numeric" has incompatible type
# "Union[ndarray[Any, Any], TimedeltaIndex, DatetimeIndex]";
# expected "ndarray[Any, Any]" [
dtype = start.dtype if start.dtype == end.dtype else np.dtype("int64")
breaks = maybe_downcast_numeric(
breaks, # type: ignore[arg-type]
np.dtype("int64"),
dtype,
)
return IntervalIndex.from_breaks(breaks, name=name, closed=closed, dtype=IntervalDtype(subtype=dtype, closed=closed))
else:
# delegate to the appropriate range function
if isinstance(endpoint, Timestamp):
Expand Down

0 comments on commit b5aa727

Please sign in to comment.