diff --git a/pandas/core/array_algos/transforms.py b/pandas/core/array_algos/transforms.py index 371425f325d76..1dde9b221a90b 100644 --- a/pandas/core/array_algos/transforms.py +++ b/pandas/core/array_algos/transforms.py @@ -19,7 +19,7 @@ def shift(values: np.ndarray, periods: int, axis: int, fill_value) -> np.ndarray new_values = new_values.T axis = new_values.ndim - axis - 1 - if np.prod(new_values.shape): + if new_values.size: new_values = np.roll(new_values, ensure_platform_int(periods), axis=axis) axis_indexer = [slice(None)] * values.ndim diff --git a/pandas/core/computation/expressions.py b/pandas/core/computation/expressions.py index 087b7f39e3374..ca62e8a31be7a 100644 --- a/pandas/core/computation/expressions.py +++ b/pandas/core/computation/expressions.py @@ -76,7 +76,7 @@ def _can_use_numexpr(op, op_str, a, b, dtype_check): if op_str is not None: # required min elements (otherwise we are adding overhead) - if np.prod(a.shape) > _MIN_ELEMENTS: + if a.size > _MIN_ELEMENTS: # check for dtype compatibility dtypes: Set[str] = set() for o in [a, b]: diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index e27c519304e2e..2fc6aa9842b73 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1497,7 +1497,7 @@ def maybe_cast_to_datetime(value, dtype: Optional[DtypeObj]): value = iNaT # we have an array of datetime or timedeltas & nulls - elif np.prod(value.shape) or not is_dtype_equal(value.dtype, dtype): + elif value.size or not is_dtype_equal(value.dtype, dtype): _disallow_mismatched_datetimelike(value, dtype) try: diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index ef645313de614..657b10c46fed7 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -429,7 +429,7 @@ def array_equivalent( # NaNs can occur in float and complex arrays. if is_float_dtype(left.dtype) or is_complex_dtype(left.dtype): - if not (np.prod(left.shape) and np.prod(right.shape)): + if not (left.size and right.size): return True return ((left == right) | (isna(left) & isna(right))).all()