Skip to content

Commit 9da81ac

Browse files
jbrockmendeljreback
authored andcommitted
CLN: remove Index/Series._is_homogeneous_type (pandas-dev#30712)
1 parent 97153bf commit 9da81ac

File tree

4 files changed

+0
-62
lines changed

4 files changed

+0
-62
lines changed

pandas/core/base.py

-18
Original file line numberDiff line numberDiff line change
@@ -628,24 +628,6 @@ def transpose(self, *args, **kwargs):
628628
""",
629629
)
630630

631-
@property
632-
def _is_homogeneous_type(self) -> bool:
633-
"""
634-
Whether the object has a single dtype.
635-
636-
By definition, Series and Index are always considered homogeneous.
637-
A MultiIndex may or may not be homogeneous, depending on the
638-
dtypes of the levels.
639-
640-
See Also
641-
--------
642-
DataFrame._is_homogeneous_type : Whether all the columns in a
643-
DataFrame have the same dtype.
644-
MultiIndex._is_homogeneous_type : Whether all the levels of a
645-
MultiIndex have the same dtype.
646-
"""
647-
return True
648-
649631
@property
650632
def shape(self):
651633
"""

pandas/core/indexes/multi.py

-25
Original file line numberDiff line numberDiff line change
@@ -661,31 +661,6 @@ def array(self):
661661
"'MultiIndex.to_numpy()' to get a NumPy array of tuples."
662662
)
663663

664-
@property
665-
def _is_homogeneous_type(self) -> bool:
666-
"""
667-
Whether the levels of a MultiIndex all have the same dtype.
668-
669-
This looks at the dtypes of the levels.
670-
671-
See Also
672-
--------
673-
Index._is_homogeneous_type : Whether the object has a single
674-
dtype.
675-
DataFrame._is_homogeneous_type : Whether all the columns in a
676-
DataFrame have the same dtype.
677-
678-
Examples
679-
--------
680-
>>> MultiIndex.from_tuples([
681-
... ('a', 'b'), ('a', 'c')])._is_homogeneous_type
682-
True
683-
>>> MultiIndex.from_tuples([
684-
... ('a', 1), ('a', 2)])._is_homogeneous_type
685-
False
686-
"""
687-
return len({x.dtype for x in self.levels}) <= 1
688-
689664
def _set_levels(
690665
self, levels, level=None, copy=False, validate=True, verify_integrity=False
691666
):

pandas/tests/indexing/multiindex/test_multiindex.py

-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import pytest
32

43
import pandas._libs.index as _index
54
from pandas.errors import PerformanceWarning
@@ -47,17 +46,6 @@ def test_multiindex_contains_dropped(self):
4746
assert "a" in idx.levels[0]
4847
assert "a" not in idx
4948

50-
@pytest.mark.parametrize(
51-
"data, expected",
52-
[
53-
(MultiIndex.from_product([(), ()]), True),
54-
(MultiIndex.from_product([(1, 2), (3, 4)]), True),
55-
(MultiIndex.from_product([("a", "b"), (1, 2)]), False),
56-
],
57-
)
58-
def test_multiindex_is_homogeneous_type(self, data, expected):
59-
assert data._is_homogeneous_type is expected
60-
6149
def test_indexing_over_hashtable_size_cutoff(self):
6250
n = 10000
6351

pandas/tests/series/test_dtypes.py

-7
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,6 @@ def test_infer_objects_series(self):
465465
assert actual.dtype == "object"
466466
tm.assert_series_equal(actual, expected)
467467

468-
def test_is_homogeneous_type(self):
469-
with tm.assert_produces_warning(DeprecationWarning, check_stacklevel=False):
470-
empty = Series()
471-
assert empty._is_homogeneous_type
472-
assert Series([1, 2])._is_homogeneous_type
473-
assert Series(pd.Categorical([1, 2]))._is_homogeneous_type
474-
475468
@pytest.mark.parametrize(
476469
"data",
477470
[

0 commit comments

Comments
 (0)