Skip to content

Commit e9845d9

Browse files
TomAugspurgerPingviinituutti
authored andcommitted
DOC: Add experimental note to DatetimeArray and TimedeltaArray (pandas-dev#24882)
* DOC: Add experimental note to DatetimeArray and TimedeltaArray
1 parent 11e0288 commit e9845d9

File tree

5 files changed

+99
-3
lines changed

5 files changed

+99
-3
lines changed

doc/source/user_guide/integer_na.rst

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Nullable Integer Data Type
1010

1111
.. versionadded:: 0.24.0
1212

13+
.. note::
14+
15+
IntegerArray is currently experimental. Its API or implementation may
16+
change without warning.
17+
18+
1319
In :ref:`missing_data`, we saw that pandas primarily uses ``NaN`` to represent
1420
missing data. Because ``NaN`` is a float, this forces an array of integers with
1521
any missing values to become floating point. In some cases, this may not matter

doc/source/whatsnew/v0.24.0.rst

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Optional Integer NA Support
3232
Pandas has gained the ability to hold integer dtypes with missing values. This long requested feature is enabled through the use of :ref:`extension types <extending.extension-types>`.
3333
Here is an example of the usage.
3434

35+
.. note::
36+
37+
IntegerArray is currently experimental. Its API or implementation may
38+
change without warning.
39+
3540
We can construct a ``Series`` with the specified dtype. The dtype string ``Int64`` is a pandas ``ExtensionDtype``. Specifying a list or array using the traditional missing value
3641
marker of ``np.nan`` will infer to integer dtype. The display of the ``Series`` will also use the ``NaN`` to indicate missing values in string outputs. (:issue:`20700`, :issue:`20747`, :issue:`22441`, :issue:`21789`, :issue:`22346`)
3742

@@ -213,6 +218,9 @@ from the ``Series``:
213218
ser.array
214219
pser.array
215220
221+
These return an instance of :class:`IntervalArray` or :class:`arrays.PeriodArray`,
222+
the new extension arrays that back interval and period data.
223+
216224
.. warning::
217225

218226
For backwards compatibility, :attr:`Series.values` continues to return

pandas/core/arrays/datetimes.py

+13
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin,
218218
219219
.. versionadded:: 0.24.0
220220
221+
.. warning::
222+
223+
DatetimeArray is currently experimental, and its API may change
224+
without warning. In particular, :attr:`DatetimeArray.dtype` is
225+
expected to change to always be an instance of an ``ExtensionDtype``
226+
subclass.
227+
221228
Parameters
222229
----------
223230
values : Series, Index, DatetimeArray, ndarray
@@ -511,6 +518,12 @@ def dtype(self):
511518
"""
512519
The dtype for the DatetimeArray.
513520
521+
.. warning::
522+
523+
A future version of pandas will change dtype to never be a
524+
``numpy.dtype``. Instead, :attr:`DatetimeArray.dtype` will
525+
always be an instance of an ``ExtensionDtype`` subclass.
526+
514527
Returns
515528
-------
516529
numpy.dtype or DatetimeTZDtype

pandas/core/arrays/integer.py

+36-3
Original file line numberDiff line numberDiff line change
@@ -225,24 +225,57 @@ class IntegerArray(ExtensionArray, ExtensionOpsMixin):
225225
"""
226226
Array of integer (optional missing) values.
227227
228+
.. versionadded:: 0.24.0
229+
230+
.. warning::
231+
232+
IntegerArray is currently experimental, and its API or internal
233+
implementation may change without warning.
234+
228235
We represent an IntegerArray with 2 numpy arrays:
229236
230237
- data: contains a numpy integer array of the appropriate dtype
231238
- mask: a boolean array holding a mask on the data, True is missing
232239
233240
To construct an IntegerArray from generic array-like input, use
234-
``integer_array`` function instead.
241+
:func:`pandas.array` with one of the integer dtypes (see examples).
242+
243+
See :ref:`integer_na` for more.
235244
236245
Parameters
237246
----------
238-
values : integer 1D numpy array
239-
mask : boolean 1D numpy array
247+
values : numpy.ndarray
248+
A 1-d integer-dtype array.
249+
mask : numpy.ndarray
250+
A 1-d boolean-dtype array indicating missing values.
240251
copy : bool, default False
252+
Whether to copy the `values` and `mask`.
241253
242254
Returns
243255
-------
244256
IntegerArray
245257
258+
Examples
259+
--------
260+
Create an IntegerArray with :func:`pandas.array`.
261+
262+
>>> int_array = pd.array([1, None, 3], dtype=pd.Int32Dtype())
263+
>>> int_array
264+
<IntegerArray>
265+
[1, NaN, 3]
266+
Length: 3, dtype: Int32
267+
268+
String aliases for the dtypes are also available. They are capitalized.
269+
270+
>>> pd.array([1, None, 3], dtype='Int32')
271+
<IntegerArray>
272+
[1, NaN, 3]
273+
Length: 3, dtype: Int32
274+
275+
>>> pd.array([1, None, 3], dtype='UInt16')
276+
<IntegerArray>
277+
[1, NaN, 3]
278+
Length: 3, dtype: UInt16
246279
"""
247280

248281
@cache_readonly

pandas/core/arrays/timedeltas.py

+36
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,29 @@ def wrapper(self, other):
107107

108108

109109
class TimedeltaArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps):
110+
"""
111+
Pandas ExtensionArray for timedelta data.
112+
113+
.. versionadded:: 0.24.0
114+
115+
.. warning::
116+
117+
TimedeltaArray is currently experimental, and its API may change
118+
without warning. In particular, :attr:`TimedeltaArray.dtype` is
119+
expected to change to be an instance of an ``ExtensionDtype``
120+
subclass.
121+
122+
Parameters
123+
----------
124+
values : array-like
125+
The timedelta data.
126+
127+
dtype : numpy.dtype
128+
Currently, only ``numpy.dtype("timedelta64[ns]")`` is accepted.
129+
freq : Offset, optional
130+
copy : bool, default False
131+
Whether to copy the underlying array of data.
132+
"""
110133
_typ = "timedeltaarray"
111134
_scalar_type = Timedelta
112135
__array_priority__ = 1000
@@ -128,6 +151,19 @@ def _box_func(self):
128151

129152
@property
130153
def dtype(self):
154+
"""
155+
The dtype for the TimedeltaArray.
156+
157+
.. warning::
158+
159+
A future version of pandas will change dtype to be an instance
160+
of a :class:`pandas.api.extensions.ExtensionDtype` subclass,
161+
not a ``numpy.dtype``.
162+
163+
Returns
164+
-------
165+
numpy.dtype
166+
"""
131167
return _TD_DTYPE
132168

133169
# ----------------------------------------------------------------

0 commit comments

Comments
 (0)