Convert a pyarrow timestamp typed array to a DatetimeArray.
(self)
| 1667 | return self |
| 1668 | |
| 1669 | def _to_datetimearray(self) -> DatetimeArray: |
| 1670 | """Convert a pyarrow timestamp typed array to a DatetimeArray.""" |
| 1671 | from pandas.core.arrays.datetimes import ( |
| 1672 | DatetimeArray, |
| 1673 | tz_to_dtype, |
| 1674 | ) |
| 1675 | |
| 1676 | pa_type = self._pa_array.type |
| 1677 | assert pa.types.is_timestamp(pa_type) |
| 1678 | np_dtype = np.dtype(f"M8[{pa_type.unit}]") |
| 1679 | dtype = tz_to_dtype(pa_type.tz, pa_type.unit) |
| 1680 | np_array = self._pa_array.to_numpy() |
| 1681 | np_array = np_array.astype(np_dtype, copy=False) |
| 1682 | return DatetimeArray._simple_new(np_array, dtype=dtype) |
| 1683 | |
| 1684 | def _to_timedeltaarray(self) -> TimedeltaArray: |
| 1685 | """Convert a pyarrow duration typed array to a TimedeltaArray.""" |
no test coverage detected