diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aec19e27a33e2..c4629048deef7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,7 +154,9 @@ jobs: source activate pandas-dev pytest pandas/tests/frame/methods --array-manager - # indexing iset related (temporary since other tests don't pass yet) + # indexing subset (temporary since other tests don't pass yet) + pytest pandas/tests/frame/indexing/test_indexing.py::TestDataFrameIndexing::test_setitem_boolean --array-manager + pytest pandas/tests/frame/indexing/test_where.py --array-manager pytest pandas/tests/frame/indexing/test_indexing.py::TestDataFrameIndexing::test_setitem_multi_index --array-manager pytest pandas/tests/frame/indexing/test_setitem.py::TestDataFrameSetItem::test_setitem_listlike_indexer_duplicate_columns --array-manager pytest pandas/tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_astype_assignment_with_dups --array-manager diff --git a/pandas/core/internals/array_manager.py b/pandas/core/internals/array_manager.py index 083f32488acd4..2c2f32f7239d4 100644 --- a/pandas/core/internals/array_manager.py +++ b/pandas/core/internals/array_manager.py @@ -7,7 +7,7 @@ import numpy as np -from pandas._libs import algos as libalgos, lib +from pandas._libs import lib from pandas._typing import ArrayLike, DtypeObj, Hashable from pandas.util._validators import validate_bool_kwarg @@ -377,28 +377,9 @@ def shift(self, periods: int, axis: int, fill_value) -> ArrayManager: ) def fillna(self, value, limit, inplace: bool, downcast) -> ArrayManager: - # TODO implement downcast - inplace = validate_bool_kwarg(inplace, "inplace") - - def array_fillna(array, value, limit, inplace): - - mask = isna(array) - if limit is not None: - limit = libalgos.validate_limit(None, limit=limit) - mask[mask.cumsum() > limit] = False - - # TODO could optimize for arrays that cannot hold NAs - # (like _can_hold_na on Blocks) - if not inplace: - array = array.copy() - - # np.putmask(array, mask, value) - if np.any(mask): - # TODO allow invalid value if there is nothing to fill? - array[mask] = value - return array - - return self.apply(array_fillna, value=value, limit=limit, inplace=inplace) + return self.apply_with_block( + "fillna", value=value, limit=limit, inplace=inplace, downcast=downcast + ) def downcast(self) -> ArrayManager: return self.apply_with_block("downcast") @@ -454,7 +435,7 @@ def is_mixed_type(self) -> bool: @property def is_numeric_mixed_type(self) -> bool: - return False + return all(is_numeric_dtype(t) for t in self.get_dtypes()) @property def any_extension_types(self) -> bool: diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index 2f098426efaf9..c057968c9574d 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -499,6 +499,7 @@ def test_where_axis(self): assert return_value is None tm.assert_frame_equal(result, expected) + def test_where_axis_multiple_dtypes(self): # Multiple dtypes (=> multiple Blocks) df = pd.concat( [