Skip to content

Commit a9b051c

Browse files
authored
DEPR: Index.is_mixed (#33291)
1 parent b71e807 commit a9b051c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

doc/source/whatsnew/v1.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ Deprecations
256256
- :meth:`DataFrame.to_dict` has deprecated accepting short names for ``orient`` in future versions (:issue:`32515`)
257257
- :meth:`Categorical.to_dense` is deprecated and will be removed in a future version, use ``np.asarray(cat)`` instead (:issue:`32639`)
258258
- The ``fastpath`` keyword in the ``SingleBlockManager`` constructor is deprecated and will be removed in a future version (:issue:`33092`)
259+
- :meth:`Index.is_mixed` is deprecated and will be removed in a future version, check ``index.inferred_type`` directly instead (:issue:`32922`)
259260

260261
.. ---------------------------------------------------------------------------
261262

pandas/core/indexes/base.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,12 @@ def is_mixed(self) -> bool:
19551955
>>> idx.is_mixed()
19561956
False
19571957
"""
1958+
warnings.warn(
1959+
"Index.is_mixed is deprecated and will be removed in a future version. "
1960+
"Check index.inferred_type directly instead.",
1961+
FutureWarning,
1962+
stacklevel=2,
1963+
)
19581964
return self.inferred_type in ["mixed"]
19591965

19601966
def holds_integer(self) -> bool:
@@ -3131,7 +3137,7 @@ def is_int(v):
31313137
# convert the slice to an indexer here
31323138

31333139
# if we are mixed and have integers
3134-
if is_positional and self.is_mixed():
3140+
if is_positional:
31353141
try:
31363142
# Validate start & stop
31373143
if start is not None:

pandas/tests/indexes/test_base.py

+6
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,12 @@ def test_intersection_difference(self, indices, sort):
11601160
diff = indices.difference(indices, sort=sort)
11611161
tm.assert_index_equal(inter, diff)
11621162

1163+
def test_is_mixed_deprecated(self):
1164+
# GH#32922
1165+
index = self.create_index()
1166+
with tm.assert_produces_warning(FutureWarning):
1167+
index.is_mixed()
1168+
11631169
@pytest.mark.parametrize(
11641170
"indices, expected",
11651171
[

0 commit comments

Comments
 (0)