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 
  * [ 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 ](integer_na.html)
  * [ 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)
  * Intro to... 

#  Intro to data structures  #

Weâll start with a quick, non-comprehensive overview of the fundamental data
structures in pandas to get you started. The fundamental behavior about data
types, indexing, axis labeling, and alignment apply across all of the objects.
To get started, import NumPy and load pandas into your namespace:

    
    
    In [1]: import numpy as np
    
    In [2]: import pandas as pd
    

Fundamentally, **data alignment is intrinsic** . The link between labels and
data will not be broken unless done so explicitly by you.

Weâll give a brief intro to the data structures, then consider all of the
broad categories of functionality and methods in separate sections.

##  Series  #

[ ` Series  ` ](../reference/api/pandas.Series.html#pandas.Series
"pandas.Series") is a one-dimensional labeled array capable of holding any
data type (integers, strings, floating point numbers, Python objects, etc.).
The axis labels are collectively referred to as the **index** . The basic
method to create a [ ` Series  `
](../reference/api/pandas.Series.html#pandas.Series "pandas.Series") is to
call:

    
    
    s = pd.Series(data, index=index)
    

Here, ` data  ` can be many different things:

  * a Python dict 

  * an ndarray 

  * a scalar value (like 5) 

The passed **index** is a list of axis labels. Thus, this separates into a few
cases depending on what **data is** :

**From ndarray**

If ` data  ` is an ndarray, **index** must be the same length as **data** . If
no index is passed, one will be created having values ` [0,  ...,  len(data)
-  1]  ` .