Skip to content

Commit e65fa90

Browse files
committed
integerarray
1 parent e068fee commit e65fa90

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

doc/source/whatsnew/v0.24.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ Optional Integer NA Support
2929
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>`.
3030
Here is an example of the usage.
3131

32+
.. note::
33+
34+
IntegerArray is currently experimental. Its API or implementation may
35+
change without warning.
36+
3237
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
3338
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`)
3439

pandas/core/arrays/integer.py

Lines changed: 36 additions & 3 deletions
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

0 commit comments

Comments
 (0)