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 
  * [ 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)
  * Reshaping... 

#  Reshaping and pivot tables  #

pandas provides methods for manipulating a [ ` Series  `
](../reference/api/pandas.Series.html#pandas.Series "pandas.Series") and [ `
DataFrame  ` ](../reference/api/pandas.DataFrame.html#pandas.DataFrame
"pandas.DataFrame") to alter the representation of the data for further data
processing or data summarization.

  * [ ` pivot()  ` ](../reference/api/pandas.pivot.html#pandas.pivot "pandas.pivot") and [ ` pivot_table()  ` ](../reference/api/pandas.pivot_table.html#pandas.pivot_table "pandas.pivot_table") : Group unique values within one or more discrete categories. 

  * [ ` stack()  ` ](../reference/api/pandas.DataFrame.stack.html#pandas.DataFrame.stack "pandas.DataFrame.stack") and [ ` unstack()  ` ](../reference/api/pandas.DataFrame.unstack.html#pandas.DataFrame.unstack "pandas.DataFrame.unstack") : Pivot a column or row level to the opposite axis respectively. 

  * [ ` melt()  ` ](../reference/api/pandas.melt.html#pandas.melt "pandas.melt") and [ ` wide_to_long()  ` ](../reference/api/pandas.wide_to_long.html#pandas.wide_to_long "pandas.wide_to_long") : Unpivot a wide [ ` DataFrame  ` ](../reference/api/pandas.DataFrame.html#pandas.DataFrame "pandas.DataFrame") to a long format. 

  * [ ` get_dummies()  ` ](../reference/api/pandas.get_dummies.html#pandas.get_dummies "pandas.get_dummies") and [ ` from_dummies()  ` ](../reference/api/pandas.from_dummies.html#pandas.from_dummies "pandas.from_dummies") : Conversions with indicator variables. 

  * [ ` explode()  ` ](../reference/api/pandas.Series.explode.html#pandas.Series.explode "panda