pandas.arrays.IntegerArray
- class pandas.arrays.IntegerArray(values, mask, copy=False)[source]
-
Array of integer (optional missing) values.
Changed in version 1.0.0: Now uses
pandas.NA
as the missing value rather thannumpy.nan
.Warning
IntegerArray is currently experimental, and its API or internal implementation may change without warning.
We represent an IntegerArray with 2 numpy arrays:
data: contains a numpy integer array of the appropriate dtype
mask: a boolean array holding a mask on the data, True is missing
To construct an IntegerArray from generic array-like input, use
pandas.array()
with one of the integer dtypes (see examples).See Nullable integer data type for more.
- Parameters
-
- values:numpy.ndarray
-
A 1-d integer-dtype array.
- mask:numpy.ndarray
-
A 1-d boolean-dtype array indicating missing values.
- copy:bool, default False
-
Whether to copy the values and mask.
- Returns
-
- IntegerArray
Examples
Create an IntegerArray with
pandas.array()
.>>> int_array = pd.array([1, None, 3], dtype=pd.Int32Dtype()) >>> int_array <IntegerArray> [1, <NA>, 3] Length: 3, dtype: Int32
String aliases for the dtypes are also available. They are capitalized.
>>> pd.array([1, None, 3], dtype='Int32') <IntegerArray> [1, <NA>, 3] Length: 3, dtype: Int32
>>> pd.array([1, None, 3], dtype='UInt16') <IntegerArray> [1, <NA>, 3] Length: 3, dtype: UInt16
Attributes
None
Methods
None
© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/api/pandas.arrays.IntegerArray.html