mteb/BrightProStackoverflowRetrieval huggingface dataset:
* [ 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.sparse.density  #

DataFrame.sparse.  density  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/arrays/sparse/accessor.py#L379-L391) #

    

Ratio of non-sparse points to total (dense) data points.

Examples

    
    
    >>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0, 1])})
    >>> df.sparse.density
    0.5
    

[ __ previous  pandas.DataFrame.hist  ](pandas.DataFrame.hist.html "previous
page") [ next  pandas.DataFrame.sparse.from_spmatrix  __
](pandas.DataFrame.sparse.from_spmatrix.html "next page")

__ On this page

  * ` DataFrame.sparse.density  `

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

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

    

The week ordinal of the year.

Examples

    
    
    >>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
    >>> idx.week  # It can be written `weekofyear`
    Index([5, 9, 13], dtype='int64')
    

[ __ previous  pandas.PeriodIndex.weekday  ](pandas.PeriodIndex.weekday.html
"previous page") [ next  pandas.PeriodIndex.year  __
](pandas.PeriodIndex.year.html "next page")

__ On this page

  * ` PeriodIndex.weekofyear  `

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

DataFrame.  idxmax  (  _ axis  =  0  _ , _ skipna  =  True  _ , _ numeric_only
=  False  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L11875-L11910) #

    

Return index of first occurrence of maximum over requested axis.

NA/null values are excluded.

Parameters  :

    

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

    

The axis to use. 0 or âindexâ for row-wise, 1 or âcolumnsâ for column-
wise.

**skipna** bool, default True

    

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

**numeric_only** bool, default False

    

Include only  float  ,  int  or  boolean  data.

New in version 1.5.0.

Returns  :

    

Series

    

Indexes of maxima along the specified axis.

Raises  :

    

ValueError

    

  * If the row/column is empty 

See also

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

    

Return index of the maximum element.

Notes

This method is the DataFrame version of ` ndarray.argmax  ` .

Examples

Consider a dataset containing food consumption in Argentina.

    
    
    >>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
    ...                     'co2_emissions': [37.2, 19.66, 1712]},
    ...                   index=['Pork', 'Wheat Products', 'Beef'])
    
    
    
    >>> df
                    consumption  co2_emissions
    Pork                  10.51         37.20
    Wheat Products       103.11         19.66
    Beef                  55.48       1712.00
    

By default, it returns the index for the maximum value in each column.

    
    
    >>> df.idxmax()
    consumption     Wheat Products
    co2_emissions             Beef
    dtype: object
    

To return the index for the maximum value in each row, use ` axis="columns"  `
.

    
    
    >>> df.idxmax(axis="columns")
    Pork              co2_emissions
    Wheat Products     consumption
    Beef              co2_emissions
    dtype: object
    

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

__ On this page

  * ` DataFrame.idxmax()  `

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

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

    

Return a tuple representing the dimensionality of the DataFrame.

See also

` ndarray.shape  `

    

Tuple of array dimensions.

Examples

    
    
    >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
    >>> df.shape
    (2, 2)
    
    
    
    >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4],
    ...                    'col3': [5, 6]})
    >>> df.shape
    (2, 3)
    

[ __ previous  pandas.DataFrame.size  ](pandas.DataFrame.size.html "previous
page") [ next  pandas.DataFrame.memory_usage  __
](pandas.DataFrame.memory_usage.html "next page")

__ On this page

  * ` DataFrame.shape  `

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

DataFrame.  itertuples  (  _ index  =  True  _ , _ name  =  'Pandas'  _ )  [
[source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L1559-L1641) #

    

Iterate over DataFrame rows as namedtuples.

Parameters  :

    

**index** bool, default True

    

If True, return the index as the first element of the tuple.

**name** str or None, default âPandasâ

    

The name of the returned namedtuples or None to return regular tuples.

Returns  :

    

iterator

    

An object to iterate over namedtuples for each row in the DataFrame with the
first field possibly being the index and following fields being the column
values.

See also

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

    

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

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

    

Iterate over (column name, Series) pairs.

Notes

The column names will be renamed to positional names if they are invalid
Python identifiers, repeated, or start with an underscore.

Examples

    
    
    >>> df = pd.DataFrame({'num_legs': [4, 2], 'num_wings': [0, 2]},
    ...                   index=['dog', 'hawk'])
    >>> df
          num_legs  num_wings
    dog          4          0
    hawk         2          2
    >>> for row in df.itertuples():
    ...     print(row)
    ...
    Pandas(Index='dog', num_legs=4, num_wings=0)
    Pandas(Index='hawk', num_legs=2, num_wings=2)
    

By setting the  index  parameter to False we can remove the index as the first
element of the tuple:

    
    
    >>> for row in df.itertuples(index=False):
    ...     print(row)
    ...
    Pandas(num_legs=4, num_wings=0)
    Pandas(num_legs=2, num_wings=2)
    

With the  name  parameter set we set a custom name for the yielded
namedtuples:

    
    
    >>> for row in df.itertuples(name='Animal'):
    ...     print(row)
    ...
    Animal(Index='dog', num_legs=4, num_wings=0)
    Animal(Index='hawk', num_legs=2, num_wings=2)
    

[ __ previous  pandas.DataFrame.iterrows  ](pandas.DataFrame.iterrows.html
"previous page") [ next  pandas.DataFrame.pop  __ ](pandas.DataFrame.pop.html
"next page")

__ On this page

  * ` DataFrame.itertuples()  `

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

_ classmethod  _ DataFrame.sparse.  from_spmatrix  (  _ data  _ , _ index  =
None  _ , _ columns  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/arrays/sparse/accessor.py#L251-L304) #

    

Create a new DataFrame from a scipy sparse matrix.

Parameters  :

    

**data** scipy.sparse.spmatrix

    

Must be convertible to csc format.

**index, columns** Index, optional

    

Row and column labels to use for the resulting DataFrame. Defaults to a
RangeIndex.

Returns  :

    

DataFrame

    

Each column of the DataFrame is stored as a [ ` arrays.SparseArray  `
](pandas.arrays.SparseArray.html#pandas.arrays.SparseArray
"pandas.arrays.SparseArray") .

Examples

    
    
    >>> import scipy.sparse
    >>> mat = scipy.sparse.eye(3, dtype=float)
    >>> pd.DataFrame.sparse.from_spmatrix(mat)
         0    1    2
    0  1.0    0    0
    1    0  1.0    0
    2    0    0  1.0
    

[ __ previous  pandas.DataFrame.sparse.density
](pandas.DataFrame.sparse.density.html "previous page") [ next
pandas.DataFrame.sparse.to_coo  __ ](pandas.DataFrame.sparse.to_coo.html "next
page")

__ On this page

  * ` DataFrame.sparse.from_spmatrix()  `

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

DataFrame.  isnull  (  )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L6494-L6499) #

    

DataFrame.isnull is an alias for DataFrame.isna.

Detect missing values.

Return a boolean same-sized object indicating if the values are NA. NA values,
such as None or ` numpy.NaN  ` , gets mapped to True values. Everything else
gets mapped to False values. Characters such as empty strings ` ''  ` or `
numpy.inf  ` are not considered NA values (unless you set `
pandas.options.mode.use_inf_as_na  =  True  ` ).

Returns  :

    

DataFrame

    

Mask of bool values for each element in DataFrame that indicates whether an
element is an NA value.

See also

` DataFrame.isnull  `

    

Alias of isna.

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

    

Boolean inverse of isna.

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

    

Omit axes labels with missing values.

[ ` isna  ` ](pandas.isna.html#pandas.isna "pandas.isna")

    

Top-level isna.

Examples

Show which entries in a DataFrame are NA.

    
    
    >>> df = pd.DataFrame(dict(age=[5, 6, np.nan],
    ...                        born=[pd.NaT, pd.Timestamp('1939-05-27'),
    ...                              pd.Timestamp('1940-04-25')],
    ...                        name=['Alfred', 'Batman', ''],
    ...                        toy=[None, 'Batmobile', 'Joker']))
    >>> df
       age       born    name        toy
    0  5.0        NaT  Alfred       None
    1  6.0 1939-05-27  Batman  Batmobile
    2  NaN 1940-04-25              Joker
    
    
    
    >>> df.isna()
         age   born   name    toy
    0  False   True  False   True
    1  False  False  False  False
    2   True  False  False  False
    

Show which entries in a Series are NA.

    
    
    >>> ser = pd.Series([5, 6, np.nan])
    >>> ser
    0    5.0
    1    6.0
    2    NaN
    dtype: float64
    
    
    
    >>> ser.isna()
    0    False
    1    False
    2     True
    dtype: bool
    

[ __ previous  pandas.DataFrame.isna  ](pandas.DataFrame.isna.html "previous
page") [ next  pandas.DataFrame.notna  __ ](pandas.DataFrame.notna.html "next
page")

__ On this page

  * ` DataFrame.isnull()  `

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

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

    

The year of the period.

Examples

    
    
    >>> idx = pd.PeriodIndex(["2023", "2024", "2025"], freq="Y")
    >>> idx.year
    Index([2023, 2024, 2025], dtype='int64')
    

[ __ previous  pandas.PeriodIndex.weekofyear
](pandas.PeriodIndex.weekofyear.html "previous page") [ next
pandas.PeriodIndex.asfreq  __ ](pandas.PeriodIndex.asfreq.html "next page")

__ On this page

  * ` PeriodIndex.year  `

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

DataFrame.  first_valid_index  (  )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L12792-L12866) #

    

Return index for first non-NA value or None, if no non-NA value is found.

Returns  :

    

type of index

    

Examples

For Series:

    
    
    >>> s = pd.Series([None, 3, 4])
    >>> s.first_valid_index()
    1
    >>> s.last_valid_index()
    2
    
    
    
    >>> s = pd.Series([None, None])
    >>> print(s.first_valid_index())
    None
    >>> print(s.last_valid_index())
    None
    

If all elements in Series are NA/null, returns None.

    
    
    >>> s = pd.Series()
    >>> print(s.first_valid_index())
    None
    >>> print(s.last_valid_index())
    None
    

If Series is empty, returns None.

For DataFrame:

    
    
    >>> df = pd.DataFrame({'A': [None, None, 2], 'B': [None, 3, 4]})
    >>> df
         A      B
    0  NaN    NaN
    1  NaN    3.0
    2  2.0    4.0
    >>> df.first_valid_index()
    1
    >>> df.last_valid_index()
    2
    
    
    
    >>> df = pd.DataFrame({'A': [None, None, None], 'B': [None, None, None]})
    >>> df
         A      B
    0  None   None
    1  None   None
    2  None   None
    >>> print(df.first_valid_index())
    None
    >>> print(df.last_valid_index())
    None
    

If all elements in DataFrame are NA/null, returns None.

    
    
    >>> df = pd.DataFrame()
    >>> df
    Empty DataFrame
    Columns: []
    Index: []
    >>> print(df.first_valid_index())
    None
    >>> print(df.last_valid_index())
    None
    

If DataFrame is empty, returns None.

[ __ previous  pandas.DataFrame.shift  ](pandas.DataFrame.shift.html "previous
page") [ next  pandas.DataFrame.last_valid_index  __
](pandas.DataFrame.last_valid_index.html "next page")

__ On this page

  * ` DataFrame.first_valid_index()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.first_valid_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.
* [ pandas.plotting.scatter_matrix ](api/pandas.plotting.scatter_matrix.html)
    * [ pandas.plotting.table ](api/pandas.plotting.table.html)
  * [ Options and settings ](options.html)
    * [ Working with options ](options.html#working-with-options)
    * [ Numeric formatting ](options.html#numeric-formatting)
  * [ Extensions ](extensions.html)
    * [ pandas.api.extensions.register_extension_dtype ](api/pandas.api.extensions.register_extension_dtype.html)
    * [ pandas.api.extensions.register_dataframe_accessor ](api/pandas.api.extensions.register_dataframe_accessor.html)
    * [ pandas.api.extensions.register_series_accessor ](api/pandas.api.extensions.register_series_accessor.html)
    * [ pandas.api.extensions.register_index_accessor ](api/pandas.api.extensions.register_index_accessor.html)
    * [ pandas.api.extensions.ExtensionDtype ](api/pandas.api.extensions.ExtensionDtype.html)
    * [ pandas.api.extensions.ExtensionArray ](api/pandas.api.extensions.ExtensionArray.html)
    * [ pandas.arrays.NumpyExtensionArray ](api/pandas.arrays.NumpyExtensionArray.html)
    * [ pandas.api.indexers.check_array_indexer ](api/pandas.api.indexers.check_array_indexer.html)
  * [ Testing ](testing.html)
    * [ Assertion functions ](testing.html#assertion-functions)
    * [ Exceptions and warnings ](testing.html#exceptions-and-warnings)
    * [ Bug report function ](testing.html#bug-report-function)
    * [ Test suite runner ](testing.html#test-suite-runner)
  * [ Missing values ](missing_value.html)
    * [ pandas.NA ](api/pandas.NA.html)
    * [ pandas.NaT ](api/pandas.NaT.html)

[ __ previous  Cookbook  ](../user_guide/cookbook.html "previous page") [ next
Input/output  __ ](io.html "next page")

[ __ Show Source ](../_sources/reference/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.
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.__iter__  #

DataFrame.  __iter__  (  )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L2015-L2032) #

    

Iterate over info axis.

Returns  :

    

iterator

    

Info axis as iterator.

Examples

    
    
    >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
    >>> for x in df:
    ...     print(x)
    A
    B
    

[ __ previous  pandas.DataFrame.insert  ](pandas.DataFrame.insert.html
"previous page") [ next  pandas.DataFrame.items  __
](pandas.DataFrame.items.html "next page")

__ On this page

  * ` DataFrame.__iter__()  `

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