Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ from the ``Series``:
ser.array
pser.array

These return an instance of :class:`IntervalArray` or :class:`arrays.PeriodArray`,
the new extension arrays that back interval and period data.

.. warning::

For backwards compatibility, :attr:`Series.values` continues to return
Expand Down
13 changes: 13 additions & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin,

.. versionadded:: 0.24.0

.. warning::

DatetimeArray is currently experimental, and its API may change
without warning. In particular, :attr:`DatetimeArray.dtype` is
expected to change to always be an instance of an ``ExtensionDtype``
subclass.

Parameters
----------
values : Series, Index, DatetimeArray, ndarray
Expand Down Expand Up @@ -511,6 +518,12 @@ def dtype(self):
"""
The dtype for the DatetimeArray.

.. warning::

A future version of pandas will change dtype to never be a
``numpy.dtype``. Instead, :attr:`DatetimeArray.dtype` will
always be an instance of an ``ExtensionDtype`` subclass.

Returns
-------
numpy.dtype or DatetimeTZDtype
Expand Down
36 changes: 36 additions & 0 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,29 @@ def wrapper(self, other):


class TimedeltaArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps):
"""
Pandas ExtensionArray for timedelta data.

.. versionadded :: 0.24.0

.. warning::

TimedeltaArray is currently experimental, and its API may change
without warning. In particular, :attr:`TimedeltaArray.dtype` is
expected to change to be an instance of an ``ExtensionDtype``
subclass.

Parameters
----------
values : array-like
The timedelta data.

dtype : numpy.dtype
Currently, only ``numpy.dtype("timedelta64[ns]")`` is accepted.
freq : Offset, optional
copy : bool, default False
Whether to copy the underlying array of data.
"""
_typ = "timedeltaarray"
_scalar_type = Timedelta
__array_priority__ = 1000
Expand All @@ -128,6 +151,19 @@ def _box_func(self):

@property
def dtype(self):
"""
The dtype for the TimedeltaArray.

.. warning::

A future version of pandas will change dtype to be an instance
of a :class:`pandas.api.extensions.ExtensionDtype` subclass,
not a ``numpy.dtype``.

Returns
-------
numpy.dtype
"""
return _TD_DTYPE

# ----------------------------------------------------------------
Expand Down