w3resource

Pandas DataFrame: iterrows() function

DataFrame - iterrows() function

The iterrows() function is used to iterate over DataFrame rows as (index, Series) pairs.

Iterates over the DataFrame columns, returning a tuple with the column name and the content as a Series.

Syntax:

DataFrame.iterrows(self)

Yields:

Name Description Type/Default Value Required / Optional
index    The index of the row. A tuple for a MultiIndex. label or tuple of label Required
data    The data of the row as a Series. Series Required
it  A generator that iterates over the rows of the frame. generator Required

Example:


Download the above Notebook from here.

Previous: DataFrame - iteritems() function
Next: DataFrame - itertuples() function