From 401e42fe92d3d9e74cc54fd07165e402aa15de54 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 26 Nov 2024 22:01:08 -0500 Subject: [PATCH] Assorted fixes --- pandas/_libs/index.pyx | 2 +- pandas/core/algorithms.py | 3 +++ pandas/core/groupby/ops.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index 1506a76aa94a6..4d7d610658e7c 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -140,7 +140,7 @@ cdef class IndexEngine: cdef readonly: ndarray values - ndarray mask + object mask HashTable mapping bint over_size_threshold diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 56f8adda93251..fdcbf2ad49fad 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -16,6 +16,7 @@ import warnings import numpy as np +from pandas_mask import PandasMaskArray from pandas._libs import ( algos, @@ -1173,6 +1174,8 @@ def take( ... ) array([ 10, 10, -10]) """ + if isinstance(arr, PandasMaskArray): # TODO: implement take directly on mask + arr = np.array(arr) if not isinstance( arr, (np.ndarray, ABCExtensionArray, ABCIndex, ABCSeries, ABCNumpyExtensionArray), diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index 4c7fe604e452d..cfade8502e699 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -324,7 +324,7 @@ def _cython_op_ndim_compat( # expand to 2d, dispatch, then squeeze if appropriate values2d = values[None, :] if mask is not None: - mask = mask[None, :] + mask = np.array(mask)[None, :] if result_mask is not None: result_mask = result_mask[None, :] res = self._call_cython_op(