Skip to content

Commit 0cc951c

Browse files
committed
unrelated changes removed
1 parent c989cdb commit 0cc951c

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

doc/source/whatsnew/v2.0.0.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ Other API changes
507507

508508
Deprecations
509509
~~~~~~~~~~~~
510-
- Deprecated argument ``infer_datetime_format`` in :func:`to_datetime` and :func:`read_csv`, as a strict version of it is now the default (:issue:`48621`)
510+
511+
- :meth:`Index.is_categorical` has been deprecated. Use :func:`pandas.api.types.is_categorical_dtype` instead (:issue:`50042`)
511512

512513
.. ---------------------------------------------------------------------------
513514

pandas/core/indexes/base.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,7 @@ def is_integer(self) -> bool:
22432243
is_floating : Check if the Index is a floating type.
22442244
is_numeric : Check if the Index only consists of numeric data.
22452245
is_object : Check if the Index is of the object dtype.
2246-
is_categorical : Check if the Index holds categorical data.
2246+
is_categorical : Check if the Index holds categorical data (deprecated).
22472247
is_interval : Check if the Index holds Interval objects.
22482248
22492249
Examples
@@ -2282,7 +2282,7 @@ def is_floating(self) -> bool:
22822282
is_integer : Check if the Index only consists of integers.
22832283
is_numeric : Check if the Index only consists of numeric data.
22842284
is_object : Check if the Index is of the object dtype.
2285-
is_categorical : Check if the Index holds categorical data.
2285+
is_categorical : Check if the Index holds categorical data (deprecated).
22862286
is_interval : Check if the Index holds Interval objects.
22872287
22882288
Examples
@@ -2321,7 +2321,7 @@ def is_numeric(self) -> bool:
23212321
is_integer : Check if the Index only consists of integers.
23222322
is_floating : Check if the Index is a floating type.
23232323
is_object : Check if the Index is of the object dtype.
2324-
is_categorical : Check if the Index holds categorical data.
2324+
is_categorical : Check if the Index holds categorical data (deprecated).
23252325
is_interval : Check if the Index holds Interval objects.
23262326
23272327
Examples
@@ -2364,7 +2364,7 @@ def is_object(self) -> bool:
23642364
is_integer : Check if the Index only consists of integers.
23652365
is_floating : Check if the Index is a floating type.
23662366
is_numeric : Check if the Index only consists of numeric data.
2367-
is_categorical : Check if the Index holds categorical data.
2367+
is_categorical : Check if the Index holds categorical data (deprecated).
23682368
is_interval : Check if the Index holds Interval objects.
23692369
23702370
Examples
@@ -2393,6 +2393,9 @@ def is_categorical(self) -> bool:
23932393
"""
23942394
Check if the Index holds categorical data.
23952395
2396+
.. deprecated:: 2.0.0
2397+
Use :meth:`pandas.api.types.is_categorical_dtype` instead.
2398+
23962399
Returns
23972400
-------
23982401
bool
@@ -2456,7 +2459,7 @@ def is_interval(self) -> bool:
24562459
is_floating : Check if the Index is a floating type.
24572460
is_numeric : Check if the Index only consists of numeric data.
24582461
is_object : Check if the Index is of the object dtype.
2459-
is_categorical : Check if the Index holds categorical data.
2462+
is_categorical : Check if the Index holds categorical data (deprecated).
24602463
24612464
Examples
24622465
--------
@@ -5002,7 +5005,11 @@ def _can_hold_identifiers_and_holds_name(self, name) -> bool:
50025005
50035006
https://github.com/pandas-dev/pandas/issues/19764
50045007
"""
5005-
if self.is_object() or is_string_dtype(self.dtype) or self.is_categorical():
5008+
if (
5009+
self.is_object()
5010+
or is_string_dtype(self.dtype)
5011+
or is_categorical_dtype(self)
5012+
):
50065013
return name in self
50075014
return False
50085015

pandas/tests/indexes/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,12 @@ def test_inv(self, simple_index):
795795
with pytest.raises(TypeError, match=msg):
796796
~Series(idx)
797797

798+
def test_is_categorical_is_deprecated(self, simple_index):
799+
# GH50042
800+
idx = simple_index
801+
with tm.assert_produces_warning(FutureWarning):
802+
idx.is_categorical()
803+
798804

799805
class NumericBase(Base):
800806
"""

0 commit comments

Comments
 (0)