Skip to content

Commit 78798cf

Browse files
committed
is_homogeneous -> is_homogeneous_type
1 parent 88c6126 commit 78798cf

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

pandas/core/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def transpose(self, *args, **kwargs):
664664
"definition self")
665665

666666
@property
667-
def _is_homogeneous(self):
667+
def _is_homogeneous_type(self):
668668
"""Whether the object has a single dtype.
669669
670670
By definition, Series and Index are always considered homogeneous.
@@ -673,8 +673,8 @@ def _is_homogeneous(self):
673673
674674
See Also
675675
--------
676-
DataFrame._is_homogeneous
677-
MultiIndex._is_homogeneous
676+
DataFrame._is_homogeneous_type
677+
MultiIndex._is_homogeneous_type
678678
"""
679679
return True
680680

pandas/core/frame.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def shape(self):
614614
return len(self.index), len(self.columns)
615615

616616
@property
617-
def _is_homogeneous(self):
617+
def _is_homogeneous_type(self):
618618
"""
619619
Whether all the columns in a DataFrame have the same type.
620620
@@ -624,16 +624,17 @@ def _is_homogeneous(self):
624624
625625
Examples
626626
--------
627-
>>> DataFrame({"A": [1, 2], "B": [3, 4]})._is_homogeneous
627+
>>> DataFrame({"A": [1, 2], "B": [3, 4]})._is_homogeneous_type
628628
True
629-
>>> DataFrame({"A": [1, 2], "B": [3.0, 4.0]})._is_homogeneous
629+
>>> DataFrame({"A": [1, 2], "B": [3.0, 4.0]})._is_homogeneous_type
630630
False
631631
632632
Items with the same type but different sizes are considered
633633
different types.
634634
635-
>>> DataFrame({"A": np.array([1, 2], dtype=np.int32),
636-
... "B": np.array([1, 2], dtype=np.int64)})._is_homogeneous
635+
>>> DataFrame({
636+
... "A": np.array([1, 2], dtype=np.int32),
637+
... "B": np.array([1, 2], dtype=np.int64)})._is_homogeneous_type
637638
False
638639
"""
639640
if self._data.any_extension_types:

pandas/core/indexes/multi.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,23 @@ def levels(self):
289289
return self._levels
290290

291291
@property
292-
def _is_homogeneous(self):
292+
def _is_homogeneous_type(self):
293293
"""Whether the levels of a MultiIndex all have the same dtype.
294294
295295
This looks at the dtypes of the levels.
296296
297297
See Also
298298
--------
299-
Index._is_homogeneous
300-
DataFrame._is_homogeneous
299+
Index._is_homogeneous_type
300+
DataFrame._is_homogeneous_type
301301
302302
Examples
303303
--------
304-
>>> MultiIndex.from_tuples([('a', 'b'), ('a', 'c')])._is_homogeneous
304+
>>> MultiIndex.from_tuples([
305+
... ('a', 'b'), ('a', 'c')])._is_homogeneous_type
305306
True
306-
>>> MultiIndex.from_tuples([('a', 1), ('a', 2)])._is_homogeneous
307+
>>> MultiIndex.from_tuples([
308+
... ('a', 1), ('a', 2)])._is_homogeneous_type
307309
False
308310
"""
309311
return len({x.dtype for x in self.levels}) <= 1

pandas/tests/frame/test_dtypes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,8 @@ def test_constructor_list_str_na(self, string_dtype):
836836
"B": pd.Categorical(['b', 'c'])}), False),
837837
838838
])
839-
def test_is_homogeneous(self, data, expected):
840-
assert data._is_homogeneous is expected
839+
def test_is_homogeneous_type(self, data, expected):
840+
assert data._is_homogeneous_type is expected
841841

842842
def test_asarray_homogenous(self):
843843
df = pd.DataFrame({"A": pd.Categorical([1, 2]),

pandas/tests/indexing/test_multiindex.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,8 @@ def test_multiindex_contains_dropped(self):
738738
(MultiIndex.from_product([(1, 2), (3, 4)]), True),
739739
(MultiIndex.from_product([('a', 'b'), (1, 2)]), False),
740740
])
741-
def test_multiindex_is_homogeneous(self, data, expected):
742-
assert data._is_homogeneous is expected
741+
def test_multiindex_is_homogeneous_type(self, data, expected):
742+
assert data._is_homogeneous_type is expected
743743

744744

745745
class TestMultiIndexSlicers(object):

pandas/tests/series/test_dtypes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def test_infer_objects_series(self):
509509
assert actual.dtype == 'object'
510510
tm.assert_series_equal(actual, expected)
511511

512-
def test_is_homogeneous(self):
513-
assert Series()._is_homogeneous
514-
assert Series([1, 2])._is_homogeneous
515-
assert Series(pd.Categorical([1, 2]))._is_homogeneous
512+
def test_is_homogeneous_type(self):
513+
assert Series()._is_homogeneous_type
514+
assert Series([1, 2])._is_homogeneous_type
515+
assert Series(pd.Categorical([1, 2]))._is_homogeneous_type

0 commit comments

Comments
 (0)