mteb/BrightProStackoverflowRetrieval huggingface dataset:
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.pad 

#  pandas.DataFrame.pad  #

DataFrame.  pad  (  _ *  _ , _ axis  =  None  _ , _ inplace  =  False  _ , _
limit  =  None  _ , _ downcast  =  _NoDefault.no_default  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L7608-L7640) #

    

Fill NA/NaN values by propagating the last valid observation to next valid.

Deprecated since version 2.0:  Series/DataFrame.pad is deprecated. Use
Series/DataFrame.ffill instead.

Returns  :

    

Series/DataFrame or None

    

Object with missing values filled or None if ` inplace=True  ` .

Examples

Please see examples for [ ` DataFrame.ffill()  `
](pandas.DataFrame.ffill.html#pandas.DataFrame.ffill "pandas.DataFrame.ffill")
or [ ` Series.ffill()  ` ](pandas.Series.ffill.html#pandas.Series.ffill
"pandas.Series.ffill") .

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

__ On this page

  * ` DataFrame.pad()  `

[ __ Show Source ](../../_sources/reference/api/pandas.DataFrame.pad.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.insert  #

DataFrame.  insert  (  _ loc  _ , _ column  _ , _ value  _ , _
allow_duplicates  =  _NoDefault.no_default  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L5095-L5172) #

    

Insert column into DataFrame at specified location.

Raises a ValueError if  column  is already contained in the DataFrame, unless
allow_duplicates  is set to True.

Parameters  :

    

**loc** int

    

Insertion index. Must verify 0 <= loc <= len(columns).

**column** str, number, or hashable object

    

Label of the inserted column.

**value** Scalar, Series, or array-like

    

Content of the inserted column.

**allow_duplicates** bool, optional, default lib.no_default

    

Allow duplicate column labels to be created.

See also

[ ` Index.insert  ` ](pandas.Index.insert.html#pandas.Index.insert
"pandas.Index.insert")

    

Insert new item by index.

Examples

    
    
    >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
    >>> df
       col1  col2
    0     1     3
    1     2     4
    >>> df.insert(1, "newcol", [99, 99])
    >>> df
       col1  newcol  col2
    0     1      99     3
    1     2      99     4
    >>> df.insert(0, "col1", [100, 100], allow_duplicates=True)
    >>> df
       col1  col1  newcol  col2
    0   100     1      99     3
    1   100     2      99     4
    

Notice that pandas uses index alignment in case of  value  from type  Series
:

    
    
    >>> df.insert(0, "col0", pd.Series([5, 6], index=[1, 2]))
    >>> df
       col0  col1  col1  newcol  col2
    0   NaN   100     1      99     3
    1   5.0   100     2      99     4
    

[ __ previous  pandas.DataFrame.iloc  ](pandas.DataFrame.iloc.html "previous
page") [ next  pandas.DataFrame.__iter__  __ ](pandas.DataFrame.__iter__.html
"next page")

__ On this page

  * ` DataFrame.insert()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.insert.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.
ndex.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.PeriodIndex ](pandas.PeriodIndex.html)
  * pandas.Perio... 

#  pandas.PeriodIndex.month  #

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

    

The month as January=1, December=12.

Examples

    
    
    >>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
    >>> idx.month
    Index([1, 2, 3], dtype='int64')
    

[ __ previous  pandas.PeriodIndex.minute  ](pandas.PeriodIndex.minute.html
"previous page") [ next  pandas.PeriodIndex.quarter  __
](pandas.PeriodIndex.quarter.html "next page")

__ On this page

  * ` PeriodIndex.month  `

[ __ Show Source
](../../_sources/reference/api/pandas.PeriodIndex.month.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_suffix  #

DataFrame.  add_suffix  (  _ suffix  _ , _ axis  =  None  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L4975-L5046) #

    

Suffix labels with string  suffix  .

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

Parameters  :

    

**suffix** str

    

The string to add after each label.

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

    

Axis to add suffix on

New in version 2.0.0.

Returns  :

    

Series or DataFrame

    

New Series or DataFrame with updated labels.

See also

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

    

Prefix row labels with string  prefix  .

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

    

Prefix column labels with string  prefix  .

Examples

    
    
    >>> s = pd.Series([1, 2, 3, 4])
    >>> s
    0    1
    1    2
    2    3
    3    4
    dtype: int64
    
    
    
    >>> s.add_suffix('_item')
    0_item    1
    1_item    2
    2_item    3
    3_item    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_suffix('_col')
         A_col  B_col
    0       1       3
    1       2       4
    2       3       5
    3       4       6
    

[ __ previous  pandas.DataFrame.add_prefix  ](pandas.DataFrame.add_prefix.html
"previous page") [ next  pandas.DataFrame.align  __
](pandas.DataFrame.align.html "next page")

__ On this page

  * ` DataFrame.add_suffix()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.add_suffix.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.
_fields ](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.from_product  #

_ classmethod  _ MultiIndex.  from_product  (  _ iterables  _ , _ sortorder  =
None  _ , _ names  =  _NoDefault.no_default  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/indexes/multi.py#L626-L685) #

    

Make a MultiIndex from the cartesian product of multiple iterables.

Parameters  :

    

**iterables** list / sequence of iterables

    

Each iterable has unique labels for each level of the index.

**sortorder** int or None

    

Level of sortedness (must be lexicographically sorted by that level).

**names** list / sequence of str, optional

    

Names for the levels in the index. If not explicitly provided, names will be
inferred from the elements of iterables if an element has a name attribute.

Returns  :

    

MultiIndex

    

See also

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

    

Convert list of arrays to MultiIndex.

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

    

Convert list of tuples to MultiIndex.

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

    

Make a MultiIndex from a DataFrame.

Examples

    
    
    >>> numbers = [0, 1, 2]
    >>> colors = ['green', 'purple']
    >>> pd.MultiIndex.from_product([numbers, colors],
    ...                            names=['number', 'color'])
    MultiIndex([(0,  'green'),
                (0, 'purple'),
                (1,  'green'),
                (1, 'purple'),
                (2,  'green'),
                (2, 'purple')],
               names=['number', 'color'])
    

[ __ previous  pandas.MultiIndex.from_tuples
](pandas.MultiIndex.from_tuples.html "previous page") [ next
pandas.MultiIndex.from_frame  __ ](pandas.MultiIndex.from_frame.html "next
page")

__ On this page

  * ` MultiIndex.from_product()  `

[ __ Show Source
](../../_sources/reference/api/pandas.MultiIndex.from_product.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.
SeriesGroupBy.resample.html)
    * [ pandas.core.groupby.SeriesGroupBy.rolling ](pandas.core.groupby.SeriesGroupBy.rolling.html)
    * [ pandas.core.groupby.SeriesGroupBy.sample ](pandas.core.groupby.SeriesGroupBy.sample.html)
    * [ pandas.core.groupby.SeriesGroupBy.sem ](pandas.core.groupby.SeriesGroupBy.sem.html)
    * [ pandas.core.groupby.SeriesGroupBy.shift ](pandas.core.groupby.SeriesGroupBy.shift.html)
    * [ pandas.core.groupby.SeriesGroupBy.size ](pandas.core.groupby.SeriesGroupBy.size.html)
    * [ pandas.core.groupby.SeriesGroupBy.skew ](pandas.core.groupby.SeriesGroupBy.skew.html)
    * [ pandas.core.groupby.SeriesGroupBy.std ](pandas.core.groupby.SeriesGroupBy.std.html)
    * [ pandas.core.groupby.SeriesGroupBy.sum ](pandas.core.groupby.SeriesGroupBy.sum.html)
    * [ pandas.core.groupby.SeriesGroupBy.var ](pandas.core.groupby.SeriesGroupBy.var.html)
    * [ pandas.core.groupby.SeriesGroupBy.tail ](pandas.core.groupby.SeriesGroupBy.tail.html)
    * [ pandas.core.groupby.SeriesGroupBy.take ](pandas.core.groupby.SeriesGroupBy.take.html)
    * pandas.core.groupby.SeriesGroupBy.value_counts 
    * [ pandas.core.groupby.DataFrameGroupBy.boxplot ](pandas.core.groupby.DataFrameGroupBy.boxplot.html)
    * [ pandas.core.groupby.DataFrameGroupBy.hist ](pandas.core.groupby.DataFrameGroupBy.hist.html)
    * [ pandas.core.groupby.SeriesGroupBy.hist ](pandas.core.groupby.SeriesGroupBy.hist.html)
    * [ pandas.core.groupby.DataFrameGroupBy.plot ](pandas.core.groupby.DataFrameGroupBy.plot.html)
    * [ pandas.core.groupby.SeriesGroupBy.plot ](pandas.core.groupby.SeriesGroupBy.plot.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)
  * [ GroupBy ](../groupby.html)
  * pandas.core.... 

#  pandas.core.groupby.SeriesGroupBy.value_counts  #

SeriesGroupBy.  value_counts  (  _ normalize  =  False  _ , _ sort  =  True  _
, _ ascending  =  False  _ , _ bins  =  None  _ , _ dropna  =  True  _ )  [
[source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/groupby/generic.py#L717-L876) #

    

[ __ previous  pandas.core.groupby.SeriesGroupBy.take
](pandas.core.groupby.SeriesGroupBy.take.html "previous page") [ next
pandas.core.groupby.DataFrameGroupBy.boxplot  __
](pandas.core.groupby.DataFrameGroupBy.boxplot.html "next page")

__ On this page

  * ` SeriesGroupBy.value_counts()  `

[ __ Show Source
](../../_sources/reference/api/pandas.core.groupby.SeriesGroupBy.value_counts.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.
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.kurtosis  #

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

    

Return unbiased kurtosis over requested axis.

Kurtosis obtained using Fisherâs definition of kurtosis (kurtosis of normal
== 0.0). Normalized by N-1.

Parameters  :

    

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

    

Axis for the function to be applied on. For  Series  this parameter is unused
and defaults to 0.

For DataFrames, specifying ` axis=None  ` will apply the aggregation across
both axes.

New in version 2.0.0.

**skipna** bool, default True

    

Exclude NA/null values when computing the result.

**numeric_only** bool, default False

    

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

****kwargs**

    

Additional keyword arguments to be passed to the function.

Returns  :

    

Series or scalar

    

Examples

    
    
    >>> s = pd.Series([1, 2, 2, 3], index=['cat', 'dog', 'dog', 'mouse'])
    >>> s
    cat    1
    dog    2
    dog    2
    mouse  3
    dtype: int64
    >>> s.kurt()
    1.5
    

With a DataFrame

    
    
    >>> df = pd.DataFrame({'a': [1, 2, 2, 3], 'b': [3, 4, 4, 4]},
    ...                   index=['cat', 'dog', 'dog', 'mouse'])
    >>> df
           a   b
      cat  1   3
      dog  2   4
      dog  2   4
    mouse  3   4
    >>> df.kurt()
    a   1.5
    b   4.0
    dtype: float64
    

With axis=None

    
    
    >>> df.kurt(axis=None).round(6)
    -0.988693
    

Using axis=1

    
    
    >>> df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [3, 4], 'd': [1, 2]},
    ...                   index=['cat', 'dog'])
    >>> df.kurt(axis=1)
    cat   -6.0
    dog   -6.0
    dtype: float64
    

[ __ previous  pandas.DataFrame.kurt  ](pandas.DataFrame.kurt.html "previous
page") [ next  pandas.DataFrame.max  __ ](pandas.DataFrame.max.html "next
page")

__ On this page

  * ` DataFrame.kurtosis()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.kurtosis.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.
by.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.attrs  #

_ property  _ DataFrame.  attrs  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L363-L399) #

    

Dictionary of global attributes of this dataset.

Warning

attrs is experimental and may change without warning.

See also

` DataFrame.flags  `

    

Global flags applying to this object.

Notes

Many operations that create new datasets will copy ` attrs  ` . Copies are
always deep so that changing ` attrs  ` will only affect the present dataset.
` pandas.concat  ` copies ` attrs  ` only if all input datasets have the same
` attrs  ` .

Examples

For Series:

    
    
    >>> ser = pd.Series([1, 2, 3])
    >>> ser.attrs = {"A": [10, 20, 30]}
    >>> ser.attrs
    {'A': [10, 20, 30]}
    

For DataFrame:

    
    
    >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
    >>> df.attrs = {"A": [10, 20, 30]}
    >>> df.attrs
    {'A': [10, 20, 30]}
    

[ __ previous  pandas.DataFrame.tz_localize
](pandas.DataFrame.tz_localize.html "previous page") [ next
pandas.DataFrame.plot  __ ](pandas.DataFrame.plot.html "next page")

__ On this page

  * ` DataFrame.attrs  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.attrs.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.
roupby.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.T 

#  pandas.DataFrame.T  #

_ property  _ DataFrame.  T  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L3951-L3978) #

    

The transpose of the DataFrame.

Returns  :

    

DataFrame

    

The transposed DataFrame.

See also

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

    

Transpose index and columns.

Examples

    
    
    >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
    >>> df
       col1  col2
    0     1     3
    1     2     4
    
    
    
    >>> df.T
          0  1
    col1  1  2
    col2  3  4
    

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

__ On this page

  * ` DataFrame.T  `

[ __ Show Source ](../../_sources/reference/api/pandas.DataFrame.T.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.
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.iterrows  #

DataFrame.  iterrows  (  )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L1505-L1557) #

    

Iterate over DataFrame rows as (index, Series) pairs.

Yields  :

    

**index** label or tuple of label

    

The index of the row. A tuple for a  MultiIndex  .

**data** Series

    

The data of the row as a Series.

See also

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

    

Iterate over DataFrame rows as namedtuples of the values.

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

    

Iterate over (column name, Series) pairs.

Notes

  1. Because ` iterrows  ` returns a Series for each row, it does **not** preserve dtypes across the rows (dtypes are preserved across columns for DataFrames). 

To preserve dtypes while iterating over the rows, it is better to use [ `
itertuples()  ` ](pandas.DataFrame.itertuples.html#pandas.DataFrame.itertuples
"pandas.DataFrame.itertuples") which returns namedtuples of the values and
which is generally faster than ` iterrows  ` .

  2. You should **never modify** something you are iterating over. This is not guaranteed to work in all cases. Depending on the data types, the iterator returns a copy and not a view, and writing to it will have no effect. 

Examples

    
    
    >>> df = pd.DataFrame([[1, 1.5]], columns=['int', 'float'])
    >>> row = next(df.iterrows())[1]
    >>> row
    int      1.0
    float    1.5
    Name: 0, dtype: float64
    >>> print(row['int'].dtype)
    float64
    >>> print(df['int'].dtype)
    int64
    

[ __ previous  pandas.DataFrame.keys  ](pandas.DataFrame.keys.html "previous
page") [ next  pandas.DataFrame.itertuples  __
](pandas.DataFrame.itertuples.html "next page")

__ On this page

  * ` DataFrame.iterrows()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.iterrows.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.