pandas.DataFrame.iterrows

DataFrame.iterrows()

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

Returns :

it : generator

A generator that iterates over the rows of the frame.

Notes

  • iterrows does not preserve dtypes across the rows (dtypes are preserved across columns for DataFrames). For example,

    >>> df = DataFrame([[1, 1.0]], columns=['x', 'y'])
    >>> row = next(df.iterrows())[1]
    >>> print(row['x'].dtype)
    float64
    >>> print(df['x'].dtype)
    int64