pandas.arrays.IntegerArray

class pandas.arrays.IntegerArray(values, mask, copy=False)[source]

Array of integer (optional missing) values.

New in version 0.24.0.

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
valuesnumpy.ndarray

A 1-d integer-dtype array.

masknumpy.ndarray

A 1-d boolean-dtype array indicating missing values.

copybool, 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, NaN, 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, NaN, 3]
Length: 3, dtype: Int32
>>> pd.array([1, None, 3], dtype='UInt16')
<IntegerArray>
[1, NaN, 3]
Length: 3, dtype: UInt16

Attributes

nbytes

The number of bytes needed to store this object in memory.

ndim

Extension Arrays are only allowed to be 1-dimensional.

shape

Return a tuple of the array dimensions.

dtype

Methods

argsort(self[, ascending, kind])

Return the indices that would sort this array.

astype(self, dtype[, copy])

Cast to a NumPy array or IntegerArray with ‘dtype’.

copy(self[, deep])

Return a copy of the array.

dropna(self)

Return ExtensionArray without NA values

factorize(self, na_sentinel)

Encode the extension array as an enumerated type.

fillna(self[, value, method, limit])

Fill NA/NaN values using the specified method.

isna(self)

A 1-D array indicating if each value is missing.

repeat(self, repeats[, axis])

Repeat elements of a ExtensionArray.

searchsorted(self, value[, side, sorter])

Find indices where elements should be inserted to maintain order.

shift(self, periods, fill_value)

Shift values by desired number.

take(self, indexer[, allow_fill, fill_value])

Take elements from an array.

unique(self)

Compute the ExtensionArray of unique values.

value_counts(self[, dropna])

Returns a Series containing counts of each category.

Scroll To Top