(
self,
value: object | ArrayLike,
limit: int | None = None,
copy: bool = True,
)
| 1406 | |
| 1407 | @doc(ExtensionArray.fillna) |
| 1408 | def fillna( |
| 1409 | self, |
| 1410 | value: object | ArrayLike, |
| 1411 | limit: int | None = None, |
| 1412 | copy: bool = True, |
| 1413 | ) -> Self: |
| 1414 | if not self._hasna: |
| 1415 | return self.copy() |
| 1416 | |
| 1417 | if limit is not None: |
| 1418 | return super().fillna(value=value, limit=limit, copy=copy) |
| 1419 | |
| 1420 | if isinstance(value, (np.ndarray, ExtensionArray)): |
| 1421 | # Similar to check_value_size, but we do not mask here since we may |
| 1422 | # end up passing it to the super() method. |
| 1423 | if len(value) != len(self): |
| 1424 | raise ValueError( |
| 1425 | f"Length of 'value' does not match. Got ({len(value)}) " |
| 1426 | f" expected {len(self)}" |
| 1427 | ) |
| 1428 | |
| 1429 | try: |
| 1430 | fill_value = self._box_pa(value, pa_type=self._pa_array.type) |
| 1431 | except pa.ArrowTypeError as err: |
| 1432 | msg = f"Invalid value '{value!s}' for dtype '{self.dtype}'" |
| 1433 | raise TypeError(msg) from err |
| 1434 | |
| 1435 | try: |
| 1436 | return self._from_pyarrow_array( |
| 1437 | _safe_fill_null(self._pa_array, fill_value=fill_value) |
| 1438 | ) |
| 1439 | except pa.ArrowNotImplementedError: |
| 1440 | # ArrowNotImplementedError: Function 'coalesce' has no kernel |
| 1441 | # matching input types (duration[ns], duration[ns]) |
| 1442 | # TODO: remove try/except wrapper if/when pyarrow implements |
| 1443 | # a kernel for duration types. |
| 1444 | pass |
| 1445 | |
| 1446 | return super().fillna(value=value, limit=limit, copy=copy) |
| 1447 | |
| 1448 | def isin(self, values: ArrayLike) -> npt.NDArray[np.bool_]: |
| 1449 | # short-circuit to return all False array. |
no test coverage detected