Teradata Package for Python Function Reference | 20.00 - itertuples - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00.00.03
Published
December 2024
ft:locale
en-US
ft:lastEdition
2024-12-19
dita:id
TeradataPython_FxRef_Enterprise_2000
lifecycle
latest
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.itertuples = itertuples(self, name='Row', num_rows=None)
DESCRIPTION:
    Method to Iterate over teradataml DataFrame rows as namedtuples.
 
PARAMETERS:
    name:
        Optional Argument.
        Specifies the name of the returned namedtuples. When set to None,
        the method returns the row in a list instead of namedtuple.
        Default Value: Row
        Types: str
 
    num_rows:
        Optional Argument.
        Specifies the number of rows to retrieve from the DataFrame.
        When set to None, the method retrieves all the records.
        Types: int OR NoneType
 
RETURNS:
    iterator, an object to iterate over namedtuples for each row in the DataFrame.
 
RAISES:
    None
 
EXAMPLES:
    # Load the data.
    >>> load_example_data("teradataml", "titanic")
 
    # Example 1: Retrieve all the records from the teradataml DataFrame.
    >>> df = DataFrame("titanic")
    >>> rows = df.itertuples()
    >>> next(rows)
    Row(passenger=78, survived=0, pclass=3, name='Moutal Mr. Rahamin Haim', sex='male', age=None, sibsp=0, parch=0, ticket='374746', fare=8.05, cabin=None, embarked='S')
    >>> next(rows)
    Row(passenger=93, survived=0, pclass=1, name='Chaffee Mr. Herbert Fuller', sex='male', age=46, sibsp=1, parch=0, ticket='W.E.P. 5734', fare=61.175, cabin='E31', embarked='S')
    >>> next(rows)
    Row(passenger=5, survived=0, pclass=3, name='Allen Mr. William Henry', sex='male', age=35, sibsp=0, parch=0, ticket='373450', fare=8.05, cabin=None, embarked='S')
    >>>
 
    # Example 2: Retrieve the first 20 records from the teradataml DataFrame in a list,
    # when DataFrame is ordered by column "passenger".
    >>> df = DataFrame("titanic")
    >>> rows = df.sort("passenger").itertuples(name=None, num_rows=20)
    >>> next(rows)
    [1, 0, 3, 'Braund, Mr. Owen Harris', 'male', 22, 1, 0, 'A/5 21171', 7.25, None, 'S']
    >>> next(rows)
    [2, 1, 1, 'Cumings, Mrs. John Bradley (Florence Briggs Thayer)', 'female', 38, 1, 0, 'PC 17599', 71.2833, 'C85', 'C']
    >>> next(rows)
    [3, 1, 3, 'Heikkinen, Miss. Laina', 'female', 26, 0, 0, 'STON/O2. 3101282', 7.925, None, 'S']