Skip to main content

__ Back to top

__ ` Ctrl ` \+ ` K `

[ ![pandas 2.2.1 documentation - Home](../_static/pandas.svg) ](../index.html)

Site Navigation

  * [ Getting started ](../getting_started/index.html)
  * [ User Guide ](index.html)
  * [ API reference ](../reference/index.html)
  * [ Development ](../development/index.html)
  * [ Release notes ](../whatsnew/index.html)

  * [ __ GitHub  ](https://github.com/pandas-dev/pandas "GitHub")
  * [ __ Twitter  ](https://twitter.com/pandas_dev "Twitter")
  * [ __ Mastodon  ](https://fosstodon.org/@pandas_dev "Mastodon")

Site Navigation

  * [ Getting started ](../getting_started/index.html)
  * [ User Guide ](index.html)
  * [ API reference ](../reference/index.html)
  * [ Development ](../development/index.html)
  * [ Release notes ](../whatsnew/index.html)

  * [ __ GitHub  ](https://github.com/pandas-dev/pandas "GitHub")
  * [ __ Twitter  ](https://twitter.com/pandas_dev "Twitter")
  * [ __ Mastodon  ](https://fosstodon.org/@pandas_dev "Mastodon")

  * [ 10 minutes to pandas ](10min.html)
  * [ Intro to data structures ](dsintro.html)
  * [ Essential basic functionality ](basics.html)
  * [ IO tools (text, CSV, HDF5, â¦) ](io.html)
  * [ PyArrow Functionality ](pyarrow.html)
  * [ Indexing and selecting data ](indexing.html)
  * [ MultiIndex / advanced indexing ](advanced.html)
  * [ Copy-on-Write (CoW) ](copy_on_write.html)
  * [ Merge, join, concatenate and compare ](merging.html)
  * [ Reshaping and pivot tables ](reshaping.html)
  * [ Working with text data ](text.html)
  * [ Working with missing data ](missing_data.html)
  * [ Duplicate Labels ](duplicates.html)
  * [ Categorical data ](categorical.html)
  * Nullable integer data type 
  * [ Nullable Boolean data type ](boolean.html)
  * [ Chart visualization ](visualization.html)
  * [ Table Visualization ](style.html)
  * [ Group by: split-apply-combine ](groupby.html)
  * [ Windowing operations ](window.html)
  * [ Time series / date functionality ](timeseries.html)
  * [ Time deltas ](timedeltas.html)
  * [ Options and settings ](options.html)
  * [ Enhancing performance ](enhancingperf.html)
  * [ Scaling to large datasets ](scale.html)
  * [ Sparse data structures ](sparse.html)
  * [ Frequently Asked Questions (FAQ) ](gotchas.html)
  * [ Cookbook ](cookbook.html)

  * [ __ ](../index.html)
  * [ User Guide ](index.html)
  * Nullable... 

#  Nullable integer data type  #

Note

IntegerArray is currently experimental. Its API or implementation may change
without warning. Uses [ ` pandas.NA  `
](../reference/api/pandas.NA.html#pandas.NA "pandas.NA") as the missing value.

In [ Working with missing data  ](missing_data.html#missing-data) , we saw
that pandas primarily uses ` NaN  ` to represent missing data. Because ` NaN
` is a float, this forces an array of integers with any missing values to
become floating point. In some cases, this may not matter much. But if your
integer column is, say, an identifier, casting to float can be problematic.
Some integers cannot even be represented as floating point numbers.

##  Construction  #

pandas can represent integer data with possibly missing values using [ `
arrays.IntegerArray  `
](../reference/api/pandas.arrays.IntegerArray.html#pandas.arrays.IntegerArray
"pandas.arrays.IntegerArray") . This is an [ extension type
](../development/extending.html#extending-extension-types) implemented within
pandas.

    
    
    In [1]: arr = pd.array([1, 2, None], dtype=pd.Int64Dtype())
    
    In [2]: arr
    Out[2]: 
    <IntegerArray>
    [1, 2, <NA>]
    Length: 3, dtype: Int64
    

Or the string alias ` "Int64"  ` (note the capital ` "I"  ` ) to differentiate
from NumPyâs ` 'int64'  ` dtype:

    
    
    In [3]: pd.array([1, 2, np.nan], dtype="Int64")
    Out[3]: 
    <IntegerArray>
    [1, 2, <NA>]
    Length: 3, dtype: Int64
    

All NA-like values are replaced with [ ` pandas.NA  `
](../reference/api/pandas.NA.html#pandas.NA "pandas.NA") .

    
    
    In [4]: pd