Wrap datetime64 and timedelta64 ndarrays in DatetimeArray/TimedeltaArray.
(arr)
| 493 | |
| 494 | |
| 495 | def ensure_wrapped_if_datetimelike(arr): |
| 496 | """ |
| 497 | Wrap datetime64 and timedelta64 ndarrays in DatetimeArray/TimedeltaArray. |
| 498 | """ |
| 499 | if isinstance(arr, np.ndarray): |
| 500 | if arr.dtype.kind == "M": |
| 501 | from pandas.core.arrays import DatetimeArray |
| 502 | |
| 503 | dtype = get_supported_dtype(arr.dtype) |
| 504 | return DatetimeArray._from_sequence(arr, dtype=dtype) |
| 505 | |
| 506 | elif arr.dtype.kind == "m": |
| 507 | from pandas.core.arrays import TimedeltaArray |
| 508 | |
| 509 | dtype = get_supported_dtype(arr.dtype) |
| 510 | return TimedeltaArray._from_sequence(arr, dtype=dtype) |
| 511 | |
| 512 | return arr |
| 513 | |
| 514 | |
| 515 | def sanitize_masked_array(data: ma.MaskedArray) -> np.ndarray: |
no test coverage detected