Skip to content

Commit a26bfb7

Browse files
ShisuiUzumakipooja-subramaniam
authored andcommitted
DEPR: deprecate Index.is_interval (pandas-dev#50196)
* assertion error fix added in pandas/core/indexes/base.py * changes made to pandas/core/infexes/base.py for is_interval deprecation in class Index * changes made to pandas/tests//indexes/common.py to test deprecation of is_interval * docs/source/whatsnew/v2.0.0.rst edited for index.is_interval * changes in pandas/core/indexes/base.py - removed extra import of is_interva;_dtype * brnahc state before rebase * Fixed error in .pre-commit-config.yaml file * unwanted changed fixed in .pre-commit-cofig.yaml
1 parent 41eafa4 commit a26bfb7

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ Deprecations
618618
- :meth:`Index.is_floating` has been deprecated. Use :func:`pandas.api.types.is_float_dtype` instead (:issue:`50042`)
619619
- :meth:`Index.holds_integer` has been deprecated. Use :func:`pandas.api.types.infer_dtype` instead (:issue:`50243`)
620620
- :meth:`Index.is_categorical` has been deprecated. Use :func:`pandas.api.types.is_categorical_dtype` instead (:issue:`50042`)
621+
- :meth:`Index.is_interval` has been deprecated. Use :func:`pandas.api.types.is_intterval_dtype` instead (:issue:`50042`)
621622

622623
.. ---------------------------------------------------------------------------
623624
.. _whatsnew_200.prior_deprecations:

pandas/core/indexes/base.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ def is_boolean(self) -> bool:
22282228
is_numeric : Check if the Index only consists of numeric data.
22292229
is_object : Check if the Index is of the object dtype.
22302230
is_categorical : Check if the Index holds categorical data.
2231-
is_interval : Check if the Index holds Interval objects.
2231+
is_interval : Check if the Index holds Interval objects (deprecated).
22322232
22332233
Examples
22342234
--------
@@ -2272,7 +2272,7 @@ def is_integer(self) -> bool:
22722272
is_numeric : Check if the Index only consists of numeric data.
22732273
is_object : Check if the Index is of the object dtype.
22742274
is_categorical : Check if the Index holds categorical data (deprecated).
2275-
is_interval : Check if the Index holds Interval objects.
2275+
is_interval : Check if the Index holds Interval objects (deprecated).
22762276
22772277
Examples
22782278
--------
@@ -2320,7 +2320,7 @@ def is_floating(self) -> bool:
23202320
is_numeric : Check if the Index only consists of numeric data.
23212321
is_object : Check if the Index is of the object dtype.
23222322
is_categorical : Check if the Index holds categorical data (deprecated).
2323-
is_interval : Check if the Index holds Interval objects.
2323+
is_interval : Check if the Index holds Interval objects (deprecated).
23242324
23252325
Examples
23262326
--------
@@ -2365,7 +2365,7 @@ def is_numeric(self) -> bool:
23652365
is_floating : Check if the Index is a floating type (deprecated).
23662366
is_object : Check if the Index is of the object dtype.
23672367
is_categorical : Check if the Index holds categorical data (deprecated).
2368-
is_interval : Check if the Index holds Interval objects.
2368+
is_interval : Check if the Index holds Interval objects (deprecated).
23692369
23702370
Examples
23712371
--------
@@ -2408,7 +2408,7 @@ def is_object(self) -> bool:
24082408
is_floating : Check if the Index is a floating type (deprecated).
24092409
is_numeric : Check if the Index only consists of numeric data.
24102410
is_categorical : Check if the Index holds categorical data (deprecated).
2411-
is_interval : Check if the Index holds Interval objects.
2411+
is_interval : Check if the Index holds Interval objects (deprecated).
24122412
24132413
Examples
24142414
--------
@@ -2452,7 +2452,7 @@ def is_categorical(self) -> bool:
24522452
is_floating : Check if the Index is a floating type (deprecated).
24532453
is_numeric : Check if the Index only consists of numeric data.
24542454
is_object : Check if the Index is of the object dtype.
2455-
is_interval : Check if the Index holds Interval objects.
2455+
is_interval : Check if the Index holds Interval objects (deprecated).
24562456
24572457
Examples
24582458
--------
@@ -2489,6 +2489,9 @@ def is_interval(self) -> bool:
24892489
"""
24902490
Check if the Index holds Interval objects.
24912491
2492+
.. deprecated:: 2.0.0
2493+
Use `pandas.api.types.is_interval_dtype` instead.
2494+
24922495
Returns
24932496
-------
24942497
bool
@@ -2515,6 +2518,12 @@ def is_interval(self) -> bool:
25152518
>>> idx.is_interval()
25162519
False
25172520
"""
2521+
warnings.warn(
2522+
f"{type(self).__name__}.is_interval is deprecated."
2523+
"Use pandas.api.types.is_interval_dtype instead",
2524+
FutureWarning,
2525+
stacklevel=find_stack_level(),
2526+
)
25182527
return self.inferred_type in ["interval"]
25192528

25202529
@final

pandas/tests/indexes/common.py

+6
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,12 @@ def test_is_categorical_is_deprecated(self, simple_index):
823823
):
824824
idx.is_categorical()
825825

826+
def test_is_interval_is_deprecated(self, simple_index):
827+
# GH50042
828+
idx = simple_index
829+
with tm.assert_produces_warning(FutureWarning):
830+
idx.is_interval()
831+
826832

827833
class NumericBase(Base):
828834
"""

0 commit comments

Comments
 (0)