Skip to main content

__ Back to top

__ ` Ctrl ` \+ ` K `

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

Site Navigation

  * [ Getting started ](../../getting_started/index.html)
  * [ User Guide ](../../user_guide/index.html)
  * [ API 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 ](../../user_guide/index.html)
  * [ API 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")

  * [ Input/output ](../io.html)
  * [ General functions ](../general_functions.html) __
    * pandas.melt 
    * [ pandas.pivot ](pandas.pivot.html)
    * [ pandas.pivot_table ](pandas.pivot_table.html)
    * [ pandas.crosstab ](pandas.crosstab.html)
    * [ pandas.cut ](pandas.cut.html)
    * [ pandas.qcut ](pandas.qcut.html)
    * [ pandas.merge ](pandas.merge.html)
    * [ pandas.merge_ordered ](pandas.merge_ordered.html)
    * [ pandas.merge_asof ](pandas.merge_asof.html)
    * [ pandas.concat ](pandas.concat.html)
    * [ pandas.get_dummies ](pandas.get_dummies.html)
    * [ pandas.from_dummies ](pandas.from_dummies.html)
    * [ pandas.factorize ](pandas.factorize.html)
    * [ pandas.unique ](pandas.unique.html)
    * [ pandas.lreshape ](pandas.lreshape.html)
    * [ pandas.wide_to_long ](pandas.wide_to_long.html)
    * [ pandas.isna ](pandas.isna.html)
    * [ pandas.isnull ](pandas.isnull.html)
    * [ pandas.notna ](pandas.notna.html)
    * [ pandas.notnull ](pandas.notnull.html)
    * [ pandas.to_numeric ](pandas.to_numeric.html)
    * [ pandas.to_datetime ](pandas.to_datetime.html)
    * [ pandas.to_timedelta ](pandas.to_timedelta.html)
    * [ pandas.date_range ](pandas.date_range.html)
    * [ pandas.bdate_range ](pandas.bdate_range.html)
    * [ pandas.period_range ](pandas.period_range.html)
    * [ pandas.timedelta_range ](pandas.timedelta_range.html)
    * [ pandas.infer_freq ](pandas.infer_freq.html)
    * [ pandas.interval_range ](pandas.interval_range.html)
    * [ pandas.eval ](pandas.eval.html)
    * [ pandas.tseries.api.guess_datetime_format ](pandas.tseries.api.guess_datetime_format.html)
    * [ pandas.util.hash_array ](pandas.util.hash_array.html)
    * [ pandas.util.hash_pandas_object ](pandas.util.hash_pandas_object.html)
    * [ pandas.api.interchange.from_dataframe ](pandas.api.interchange.from_dataframe.html)
  * [ Series ](../series.html)
  * [ DataFrame ](../frame.html)
  * [ pandas arrays, scalars, and data types ](../arrays.html)
  * [ Index objects ](../indexing.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ General functions ](../general_functions.html)
  * pandas.melt 

#  pandas.melt  #

pandas.  melt  (  _ frame  _ , _ id_vars  =  None  _ , _ value_vars  =  None
_ , _ var_name  =  None  _ , _ value_name  =  'value'  _ , _ col_level  =
None  _ , _ ignore_index  =  True  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/reshape/melt.py#L43-L138) #

    

Unpivot a DataFrame from wide to long format, optionally leaving