Skip to content

Commit 25527f7

Browse files
chean.wei.khorchean.wei.khor
chean.wei.khor
authored and
chean.wei.khor
committed
add message
1 parent 0429a72 commit 25527f7

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

pandas/core/indexes/interval.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Hashable,
1212
Literal,
1313
)
14+
import warnings
1415

1516
import numpy as np
1617

@@ -954,7 +955,8 @@ def interval_range(
954955
periods=None,
955956
freq=None,
956957
name: Hashable = None,
957-
inclusive: IntervalClosedType = "right",
958+
closed: lib.NoDefault = lib.no_default,
959+
inclusive: str | None = None,
958960
) -> IntervalIndex:
959961
"""
960962
Return a fixed frequency IntervalIndex.
@@ -1050,6 +1052,27 @@ def interval_range(
10501052
IntervalIndex([[1, 2], [2, 3], [3, 4], [4, 5]],
10511053
dtype='interval[int64, both]')
10521054
"""
1055+
if inclusive is not None and not isinstance(closed, lib.NoDefault):
1056+
raise ValueError(
1057+
"Deprecated argument `closed` cannot be passed "
1058+
"if argument `inclusive` is not None"
1059+
)
1060+
elif not isinstance(closed, lib.NoDefault):
1061+
warnings.warn(
1062+
"Argument `closed` is deprecated in favor of `inclusive`.",
1063+
FutureWarning,
1064+
stacklevel=2,
1065+
)
1066+
if closed is None:
1067+
inclusive = "both"
1068+
elif closed in ("both", "neither", "left", "right"):
1069+
inclusive = closed
1070+
else:
1071+
raise ValueError(
1072+
"Argument `closed` has to be either 'both', 'neither', 'left', 'right',"
1073+
"or 'both'"
1074+
)
1075+
10531076
start = maybe_box_datetimelike(start)
10541077
end = maybe_box_datetimelike(end)
10551078
endpoint = start if start is not None else end

0 commit comments

Comments
 (0)