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 Pandas DataFrame Notebooks from here.

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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/dataframe/dataframe-itertuples.php