mteb/BrightProStackoverflowRetrieval huggingface dataset:
y.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)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.filter  #

DataFrame.  filter  (  _ items  =  None  _ , _ like  =  None  _ , _ regex  =
None  _ , _ axis  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L5710-L5816) #

    

Subset the dataframe rows or columns according to the specified index labels.

Note that this routine does not filter a dataframe on its contents. The filter
is applied to the labels of the index.

Parameters  :

    

**items** list-like

    

Keep labels from axis which are in items.

**like** str

    

Keep labels from axis for which âlike in label == Trueâ.

**regex** str (regular expression)

    

Keep labels from axis for which re.search(regex, label) == True.

**axis** {0 or âindexâ, 1 or âcolumnsâ, None}, default None

    

The axis to filter on, expressed either as an index (int) or axis name (str).
By default this is the info axis, âcolumnsâ for DataFrame. For  Series
this parameter is unused and defaults to  None  .

Returns  :

    

same type as input object

    

See also

[ ` DataFrame.loc  ` ](pandas.DataFrame.loc.html#pandas.DataFrame.loc
"pandas.DataFrame.loc")

    

Access a group of rows and columns by label(s) or a boolean array.

Notes

The ` items  ` , ` like  ` , and ` regex  ` parameters are enforced to be
mutually exclusive.

` axis  ` defaults to the info axis that is used when indexing with ` []  ` .

Examples

    
    
    >>> df = pd.DataFrame(np.array(([1, 2, 3], [4, 5, 6])),
    ...                   index=['mouse', 'rabbit'],
    ...                   columns=['one', 'two', 'three'])
    >>> df
            one  two  three
    mouse     1    2      3
    rabbit    4    5      6
    
    
    
    >>> # select columns by name
    >>> df.filter(items=['one', 'three'])
             one  three
    mouse     1      3
    rabbit    4      6
    
    
    
    >>> # select columns by regular expression
    >>> df.filter(regex='e$', axis=1)
             one  three
    mouse     1      3
    rabbit    4      6
    
    
    
    >>> # select rows containing 'bbi'
    >>> df.filter(like='bbi', axis=0)
             one  two  three
    rabbit    4    5      6
    

[ __ previous  pandas.DataFrame.equals  ](pandas.DataFrame.equals.html
"previous page") [ next  pandas.DataFrame.first  __
](pandas.DataFrame.first.html "next page")

__ On this page

  * ` DataFrame.filter()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.filter.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
ordinals.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)
  * __
  * [ pandas.PeriodIndex ](pandas.PeriodIndex.html)
  * pandas.Perio... 

#  pandas.PeriodIndex.start_time  #

_ property  _ PeriodIndex.  start_time  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/indexes/extension.py#L67-L75) #

    

Get the Timestamp for the start of the period.

Returns  :

    

Timestamp

    

See also

[ ` Period.end_time  ` ](pandas.Period.end_time.html#pandas.Period.end_time
"pandas.Period.end_time")

    

Return the end Timestamp.

[ ` Period.dayofyear  ` ](pandas.Period.dayofyear.html#pandas.Period.dayofyear
"pandas.Period.dayofyear")

    

Return the day of year.

[ ` Period.daysinmonth  `
](pandas.Period.daysinmonth.html#pandas.Period.daysinmonth
"pandas.Period.daysinmonth")

    

Return the days in that month.

[ ` Period.dayofweek  ` ](pandas.Period.dayofweek.html#pandas.Period.dayofweek
"pandas.Period.dayofweek")

    

Return the day of the week.

Examples

    
    
    >>> period = pd.Period('2012-1-1', freq='D')
    >>> period
    Period('2012-01-01', 'D')
    
    
    
    >>> period.start_time
    Timestamp('2012-01-01 00:00:00')
    
    
    
    >>> period.end_time
    Timestamp('2012-01-01 23:59:59.999999999')
    

[ __ previous  pandas.PeriodIndex.second  ](pandas.PeriodIndex.second.html
"previous page") [ next  pandas.PeriodIndex.week  __
](pandas.PeriodIndex.week.html "next page")

__ On this page

  * ` PeriodIndex.start_time  `

[ __ Show Source
](../../_sources/reference/api/pandas.PeriodIndex.start_time.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
upby.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)
  * [ DataFrame ](../frame.html)
  * pandas.DataFrame.get 

#  pandas.DataFrame.get  #

DataFrame.  get  (  _ key  _ , _ default  =  None  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L4526-L4583) #

    

Get item from object for given key (ex: DataFrame column).

Returns default value if not found.

Parameters  :

    

**key** object

    
Returns  :

    

same type as items contained in object

    

Examples

    
    
    >>> df = pd.DataFrame(
    ...     [
    ...         [24.3, 75.7, "high"],
    ...         [31, 87.8, "high"],
    ...         [22, 71.6, "medium"],
    ...         [35, 95, "medium"],
    ...     ],
    ...     columns=["temp_celsius", "temp_fahrenheit", "windspeed"],
    ...     index=pd.date_range(start="2014-02-12", end="2014-02-15", freq="D"),
    ... )
    
    
    
    >>> df
                temp_celsius  temp_fahrenheit windspeed
    2014-02-12          24.3             75.7      high
    2014-02-13          31.0             87.8      high
    2014-02-14          22.0             71.6    medium
    2014-02-15          35.0             95.0    medium
    
    
    
    >>> df.get(["temp_celsius", "windspeed"])
                temp_celsius windspeed
    2014-02-12          24.3      high
    2014-02-13          31.0      high
    2014-02-14          22.0    medium
    2014-02-15          35.0    medium
    
    
    
    >>> ser = df['windspeed']
    >>> ser.get('2014-02-13')
    'high'
    

If the key isnât found, the default value will be used.

    
    
    >>> df.get(["temp_celsius", "temp_kelvin"], default="default_value")
    'default_value'
    
    
    
    >>> ser.get('2014-02-10', '[unknown]')
    '[unknown]'
    

[ __ previous  pandas.DataFrame.xs  ](pandas.DataFrame.xs.html "previous
page") [ next  pandas.DataFrame.isin  __ ](pandas.DataFrame.isin.html "next
page")

__ On this page

  * ` DataFrame.get()  `

[ __ Show Source ](../../_sources/reference/api/pandas.DataFrame.get.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
tml)
  * [ 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)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.droplevel  #

DataFrame.  droplevel  (  _ level  _ , _ axis  =  0  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L881-L944) #

    

Return Series/DataFrame with requested index / column level(s) removed.

Parameters  :

    

**level** int, str, or list-like

    

If a string is given, must be the name of a level If list-like, elements must
be names or positional indexes of levels.

**axis** {0 or âindexâ, 1 or âcolumnsâ}, default 0

    

Axis along which the level(s) is removed:

  * 0 or âindexâ: remove level(s) in column. 

  * 1 or âcolumnsâ: remove level(s) in row. 

For  Series  this parameter is unused and defaults to 0.

Returns  :

    

Series/DataFrame

    

Series/DataFrame with requested index / column level(s) removed.

Examples

    
    
    >>> df = pd.DataFrame([
    ...     [1, 2, 3, 4],
    ...     [5, 6, 7, 8],
    ...     [9, 10, 11, 12]
    ... ]).set_index([0, 1]).rename_axis(['a', 'b'])
    
    
    
    >>> df.columns = pd.MultiIndex.from_tuples([
    ...     ('c', 'e'), ('d', 'f')
    ... ], names=['level_1', 'level_2'])
    
    
    
    >>> df
    level_1   c   d
    level_2   e   f
    a b
    1 2      3   4
    5 6      7   8
    9 10    11  12
    
    
    
    >>> df.droplevel('a')
    level_1   c   d
    level_2   e   f
    b
    2        3   4
    6        7   8
    10      11  12
    
    
    
    >>> df.droplevel('level_2', axis=1)
    level_1   c   d
    a b
    1 2      3   4
    5 6      7   8
    9 10    11  12
    

[ __ previous  pandas.DataFrame.replace  ](pandas.DataFrame.replace.html
"previous page") [ next  pandas.DataFrame.pivot  __
](pandas.DataFrame.pivot.html "next page")

__ On this page

  * ` DataFrame.droplevel()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.droplevel.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
upby.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)
  * [ DataFrame ](../frame.html)
  * pandas.DataFrame.var 

#  pandas.DataFrame.var  #

DataFrame.  var  (  _ axis  =  0  _ , _ skipna  =  True  _ , _ ddof  =  1  _ ,
_ numeric_only  =  False  _ , _ **  kwargs  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L11725-L11737) #

    

Return unbiased variance over requested axis.

Normalized by N-1 by default. This can be changed using the ddof argument.

Parameters  :

    

**axis** {index (0), columns (1)}

    

For  Series  this parameter is unused and defaults to 0.

Warning

The behavior of DataFrame.var with ` axis=None  ` is deprecated, in a future
version this will reduce over both axes and return a scalar To retain the old
behavior, pass axis=0 (or do not pass axis).

**skipna** bool, default True

    

Exclude NA/null values. If an entire row/column is NA, the result will be NA.

**ddof** int, default 1

    

Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where
N represents the number of elements.

**numeric_only** bool, default False

    

Include only float, int, boolean columns. Not implemented for Series.

Returns  :

    

Series or DataFrame (if level specified)

    

Examples

    
    
    >>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
    ...                    'age': [21, 25, 62, 43],
    ...                    'height': [1.61, 1.87, 1.49, 2.01]}
    ...                   ).set_index('person_id')
    >>> df
               age  height
    person_id
    0           21    1.61
    1           25    1.87
    2           62    1.49
    3           43    2.01
    
    
    
    >>> df.var()
    age       352.916667
    height      0.056367
    dtype: float64
    

Alternatively, ` ddof=0  ` can be set to normalize by N instead of N-1:

    
    
    >>> df.var(ddof=0)
    age       264.687500
    height      0.042275
    dtype: float64
    

[ __ previous  pandas.DataFrame.std  ](pandas.DataFrame.std.html "previous
page") [ next  pandas.DataFrame.nunique  __ ](pandas.DataFrame.nunique.html
"next page")

__ On this page

  * ` DataFrame.var()  `

[ __ Show Source ](../../_sources/reference/api/pandas.DataFrame.var.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
upby.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)
  * [ DataFrame ](../frame.html)
  * pandas.DataFrame.std 

#  pandas.DataFrame.std  #

DataFrame.  std  (  _ axis  =  0  _ , _ skipna  =  True  _ , _ ddof  =  1  _ ,
_ numeric_only  =  False  _ , _ **  kwargs  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L11739-L11751) #

    

Return sample standard deviation over requested axis.

Normalized by N-1 by default. This can be changed using the ddof argument.

Parameters  :

    

**axis** {index (0), columns (1)}

    

For  Series  this parameter is unused and defaults to 0.

Warning

The behavior of DataFrame.std with ` axis=None  ` is deprecated, in a future
version this will reduce over both axes and return a scalar To retain the old
behavior, pass axis=0 (or do not pass axis).

**skipna** bool, default True

    

Exclude NA/null values. If an entire row/column is NA, the result will be NA.

**ddof** int, default 1

    

Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where
N represents the number of elements.

**numeric_only** bool, default False

    

Include only float, int, boolean columns. Not implemented for Series.

Returns  :

    

Series or DataFrame (if level specified)

    

Notes

To have the same behaviour as  numpy.std  , use  ddof=0  (instead of the
default  ddof=1  )

Examples

    
    
    >>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
    ...                    'age': [21, 25, 62, 43],
    ...                    'height': [1.61, 1.87, 1.49, 2.01]}
    ...                   ).set_index('person_id')
    >>> df
               age  height
    person_id
    0           21    1.61
    1           25    1.87
    2           62    1.49
    3           43    2.01
    

The standard deviation of the columns can be found as follows:

    
    
    >>> df.std()
    age       18.786076
    height     0.237417
    dtype: float64
    

Alternatively,  ddof=0  can be set to normalize by N instead of N-1:

    
    
    >>> df.std(ddof=0)
    age       16.269219
    height     0.205609
    dtype: float64
    

[ __ previous  pandas.DataFrame.sum  ](pandas.DataFrame.sum.html "previous
page") [ next  pandas.DataFrame.var  __ ](pandas.DataFrame.var.html "next
page")

__ On this page

  * ` DataFrame.std()  `

[ __ Show Source ](../../_sources/reference/api/pandas.DataFrame.std.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
y.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)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.assign  #

DataFrame.  assign  (  _ **  kwargs  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L5174-L5240) #

    

Assign new columns to a DataFrame.

Returns a new object with all original columns in addition to new ones.
Existing columns that are re-assigned will be overwritten.

Parameters  :

    

****kwargs** dict of {str: callable or Series}

    

The column names are keywords. If the values are callable, they are computed
on the DataFrame and assigned to the new columns. The callable must not change
input DataFrame (though pandas doesnât check it). If the values are not
callable, (e.g. a Series, scalar, or array), they are simply assigned.

Returns  :

    

DataFrame

    

A new DataFrame with the new columns in addition to all the existing columns.

Notes

Assigning multiple columns within the same ` assign  ` is possible. Later
items in â**kwargsâ may refer to newly created or modified columns in
âdfâ; items are computed and assigned into âdfâ in order.

Examples

    
    
    >>> df = pd.DataFrame({'temp_c': [17.0, 25.0]},
    ...                   index=['Portland', 'Berkeley'])
    >>> df
              temp_c
    Portland    17.0
    Berkeley    25.0
    

Where the value is a callable, evaluated on  df  :

    
    
    >>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
              temp_c  temp_f
    Portland    17.0    62.6
    Berkeley    25.0    77.0
    

Alternatively, the same behavior can be achieved by directly referencing an
existing Series or sequence:

    
    
    >>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
              temp_c  temp_f
    Portland    17.0    62.6
    Berkeley    25.0    77.0
    

You can create multiple columns within the same assign where one of the
columns depends on another one defined within the same assign:

    
    
    >>> df.assign(temp_f=lambda x: x['temp_c'] * 9 / 5 + 32,
    ...           temp_k=lambda x: (x['temp_f'] + 459.67) * 5 / 9)
              temp_c  temp_f  temp_k
    Portland    17.0    62.6  290.15
    Berkeley    25.0    77.0  298.15
    

[ __ previous  pandas.DataFrame.transpose  ](pandas.DataFrame.transpose.html
"previous page") [ next  pandas.DataFrame.compare  __
](pandas.DataFrame.compare.html "next page")

__ On this page

  * ` DataFrame.assign()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.assign.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
ml)
  * [ 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)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.add_prefix  #

DataFrame.  add_prefix  (  _ prefix  _ , _ axis  =  None  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L4901-L4973) #

    

Prefix labels with string  prefix  .

For Series, the row labels are prefixed. For DataFrame, the column labels are
prefixed.

Parameters  :

    

**prefix** str

    

The string to add before each label.

**axis** {0 or âindexâ, 1 or âcolumnsâ, None}, default None

    

Axis to add prefix on

New in version 2.0.0.

Returns  :

    

Series or DataFrame

    

New Series or DataFrame with updated labels.

See also

[ ` Series.add_suffix  `
](pandas.Series.add_suffix.html#pandas.Series.add_suffix
"pandas.Series.add_suffix")

    

Suffix row labels with string  suffix  .

[ ` DataFrame.add_suffix  `
](pandas.DataFrame.add_suffix.html#pandas.DataFrame.add_suffix
"pandas.DataFrame.add_suffix")

    

Suffix column labels with string  suffix  .

Examples

    
    
    >>> s = pd.Series([1, 2, 3, 4])
    >>> s
    0    1
    1    2
    2    3
    3    4
    dtype: int64
    
    
    
    >>> s.add_prefix('item_')
    item_0    1
    item_1    2
    item_2    3
    item_3    4
    dtype: int64
    
    
    
    >>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
    >>> df
       A  B
    0  1  3
    1  2  4
    2  3  5
    3  4  6
    
    
    
    >>> df.add_prefix('col_')
         col_A  col_B
    0       1       3
    1       2       4
    2       3       5
    3       4       6
    

[ __ previous  pandas.DataFrame.value_counts
](pandas.DataFrame.value_counts.html "previous page") [ next
pandas.DataFrame.add_suffix  __ ](pandas.DataFrame.add_suffix.html "next
page")

__ On this page

  * ` DataFrame.add_prefix()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.add_prefix.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.
ields ](pandas.PeriodIndex.from_fields.html)
    * [ pandas.PeriodIndex.from_ordinals ](pandas.PeriodIndex.from_ordinals.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)
  * __
  * [ pandas.MultiIndex ](pandas.MultiIndex.html)
  * pandas.Multi... 

#  pandas.MultiIndex.to_flat_index  #

MultiIndex.  to_flat_index  (  )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/indexes/multi.py#L1936-L1964) #

    

Convert a MultiIndex to an Index of Tuples containing the level values.

Returns  :

    

pd.Index

    

Index with the MultiIndex data represented in Tuples.

See also

[ ` MultiIndex.from_tuples  `
](pandas.MultiIndex.from_tuples.html#pandas.MultiIndex.from_tuples
"pandas.MultiIndex.from_tuples")

    

Convert flat index back to MultiIndex.

Notes

This method will simply return the caller if called by anything other than a
MultiIndex.

Examples

    
    
    >>> index = pd.MultiIndex.from_product(
    ...     [['foo', 'bar'], ['baz', 'qux']],
    ...     names=['a', 'b'])
    >>> index.to_flat_index()
    Index([('foo', 'baz'), ('foo', 'qux'),
           ('bar', 'baz'), ('bar', 'qux')],
          dtype='object')
    

[ __ previous  pandas.MultiIndex.to_frame  ](pandas.MultiIndex.to_frame.html
"previous page") [ next  pandas.MultiIndex.sortlevel  __
](pandas.MultiIndex.sortlevel.html "next page")

__ On this page

  * ` MultiIndex.to_flat_index()  `

[ __ Show Source
](../../_sources/reference/api/pandas.MultiIndex.to_flat_index.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.