Teradata Package for Python Function Reference | 20.00 - sequence - 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
VMware
Enterprise
IntelliFlex
Product
Teradata Package for Python
Release Number
20.00.00.11
Published
August 2026
ft:locale
en-US
ft:lastEdition
2026-08-13
dita:id
TeradataPython_FxRef_Enterprise_2000
Product Category
Teradata Vantage
teradataml.dataframe.functions.sequence = sequence(start, stop, step=1, atype=ARRAY_INTEGER('[100]'))
DESCRIPTION:
    Generate a array of numbers from start to stop with given step.
 
PARAMETERS:
    start:
        Required Argument.
        Specifies the starting value of the sequence (inclusive).
        Types: ColumnExpression OR int
 
    stop:
        Required Argument.
        Specifies the ending value of the sequence (inclusive).
        Types: ColumnExpression OR int
 
    step:
        Optional Argument.
        Specifies the step size for the sequence.
        Default Value: 1
        Types: ColumnExpression OR int
 
    atype:
        Optional Argument.
        Specifies the desired array type of the output.
        Note:
            * The 'atype' must be compatible with INTEGER type value.
        Default Value: ARRAY_INTEGER('[100]')
        Types: teradatasqlalchemy types object
 
RETURNS:
    ColumnExpression
 
EXAMPLES:
    >>> from teradataml.dataframe.functions import sequence
    # Load the data to run the example.
    >>> load_example_data("dataframe", "sales")
 
    # Create a DataFrame on 'sales' table.
    >>> df = DataFrame("sales")
    >>> df
                Feb    Jan    Mar    Apr    datetime
    accounts                                          
    Yellow Inc   90.0    NaN    NaN    NaN  04/01/2017
    Jones LLC   200.0  150.0  140.0  180.0  04/01/2017
    Red Inc     200.0  150.0  140.0    NaN  04/01/2017
    Alpha Co    210.0  200.0  215.0  250.0  04/01/2017
    Blue Inc     90.0   50.0   95.0  101.0  04/01/2017
    Orange Inc  210.0    NaN    NaN  250.0  04/01/2017
 
    # Example 1: Create a array column 'arr_seq' with sequence from 1 to 5.
    >>> res = df.assign(arr_seq = sequence(1, 5))
    >>> res
                  Feb    Jan    Mar    Apr  datetime      arr_seq
    accounts                                                     
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04  (1,2,3,4,5)
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04  (1,2,3,4,5)
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04  (1,2,3,4,5)
    Red Inc     200.0  150.0  140.0    NaN  17/01/04  (1,2,3,4,5)
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04  (1,2,3,4,5)
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04  (1,2,3,4,5)
 
    # Example 2: Create a array column 'arr_seq' with step size of 2 from 1 to 10.
    >>> res = df.assign(arr_seq = sequence(-10, 5 , 2, atype=ARRAY_BIGINT('[100]')))
    >>> res
                  Feb    Jan    Mar    Apr  datetime                  arr_seq
    accounts                                                                 
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04  (-10,-8,-6,-4,-2,0,2,4)
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04  (-10,-8,-6,-4,-2,0,2,4)
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04  (-10,-8,-6,-4,-2,0,2,4)
    Red Inc     200.0  150.0  140.0    NaN  17/01/04  (-10,-8,-6,-4,-2,0,2,4)
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04  (-10,-8,-6,-4,-2,0,2,4)
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04  (-10,-8,-6,-4,-2,0,2,4)
 
    >>> res.tdtypes
    accounts    VARCHAR(length=20, charset='LATIN')
    Feb                                     FLOAT()
    Jan                                    BIGINT()
    Mar                                    BIGINT()
    Apr                                    BIGINT()
    datetime                                 DATE()
    arr_seq                   ARRAY_BIGINT('[100]')
 
    # Example 3: Create a array column 'arr_seq' with sequence in columns 'start_col', 'stop_col' and 'step_col'.
    >>> tdf = df.assign(start_col = 4, stop_col = -6, step_col = -3)
    >>> res = tdf.assign(arr_seq = sequence(tdf.start_col, tdf.stop_col, tdf.step_col))
    >>> res
                  Feb    Jan    Mar    Apr  datetime  start_col  step_col  stop_col      arr_seq
    accounts                                                                                    
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04          4        -3        -6  (4,1,-2,-5)
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04          4        -3        -6  (4,1,-2,-5)
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04          4        -3        -6  (4,1,-2,-5)
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04          4        -3        -6  (4,1,-2,-5)
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04          4        -3        -6  (4,1,-2,-5)
    Red Inc     200.0  150.0  140.0    NaN  17/01/04          4        -3        -6  (4,1,-2,-5)