w3resource

Pandas DataFrame: itertuples() function

DataFrame - itertuples() function

The itertuples() function is used to iterate over DataFrame rows as namedtuples.

Syntax:

DataFrame.itertuples(self, index=True, name='Pandas')

Parameters:

Name Description Type/Default Value Required / Optional
index    If True, return the index as the first element of the tuple. bool
Default Value: True
Required
name     The name of the returned namedtuples or None to return regular tuples. str or None
Default Value: “Pandas”
Required

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.

Example:


Download the above Notebook from here.

Previous: DataFrame - iterrows() function
Next: DataFrame - lookup() function