|
20 | 20 | is_integer_dtype,
|
21 | 21 | is_list_like,
|
22 | 22 | is_object_dtype,
|
23 |
| - is_scalar, |
24 | 23 | pandas_dtype,
|
25 | 24 | )
|
26 | 25 | from pandas.core.dtypes.dtypes import register_extension_dtype
|
27 | 26 | from pandas.core.dtypes.missing import isna
|
28 | 27 |
|
29 |
| -from pandas.core import nanops, ops |
| 28 | +from pandas.core import ops |
30 | 29 | from pandas.core.array_algos import masked_reductions
|
31 |
| -from pandas.core.indexers import check_array_indexer |
32 | 30 | from pandas.core.ops import invalid_comparison
|
33 | 31 | from pandas.core.ops.common import unpack_zerodim_and_defer
|
34 | 32 | from pandas.core.tools.numeric import to_numeric
|
@@ -417,19 +415,8 @@ def reconstruct(x):
|
417 | 415 | else:
|
418 | 416 | return reconstruct(result)
|
419 | 417 |
|
420 |
| - def __setitem__(self, key, value) -> None: |
421 |
| - _is_scalar = is_scalar(value) |
422 |
| - if _is_scalar: |
423 |
| - value = [value] |
424 |
| - value, mask = coerce_to_array(value, dtype=self.dtype) |
425 |
| - |
426 |
| - if _is_scalar: |
427 |
| - value = value[0] |
428 |
| - mask = mask[0] |
429 |
| - |
430 |
| - key = check_array_indexer(self, key) |
431 |
| - self._data[key] = value |
432 |
| - self._mask[key] = mask |
| 418 | + def _coerce_to_array(self, value) -> Tuple[np.ndarray, np.ndarray]: |
| 419 | + return coerce_to_array(value, dtype=self.dtype) |
433 | 420 |
|
434 | 421 | def astype(self, dtype, copy: bool = True) -> ArrayLike:
|
435 | 422 | """
|
@@ -553,27 +540,6 @@ def cmp_method(self, other):
|
553 | 540 | name = f"__{op.__name__}__"
|
554 | 541 | return set_function_name(cmp_method, name, cls)
|
555 | 542 |
|
556 |
| - def _reduce(self, name: str, skipna: bool = True, **kwargs): |
557 |
| - data = self._data |
558 |
| - mask = self._mask |
559 |
| - |
560 |
| - if name in {"sum", "prod", "min", "max"}: |
561 |
| - op = getattr(masked_reductions, name) |
562 |
| - return op(data, mask, skipna=skipna, **kwargs) |
563 |
| - |
564 |
| - # coerce to a nan-aware float if needed |
565 |
| - # (we explicitly use NaN within reductions) |
566 |
| - if self._hasna: |
567 |
| - data = self.to_numpy("float64", na_value=np.nan) |
568 |
| - |
569 |
| - op = getattr(nanops, "nan" + name) |
570 |
| - result = op(data, axis=0, skipna=skipna, mask=mask, **kwargs) |
571 |
| - |
572 |
| - if np.isnan(result): |
573 |
| - return libmissing.NA |
574 |
| - |
575 |
| - return result |
576 |
| - |
577 | 543 | def sum(self, skipna=True, min_count=0, **kwargs):
|
578 | 544 | nv.validate_sum((), kwargs)
|
579 | 545 | result = masked_reductions.sum(
|
|
0 commit comments