Teradata Package for Python Function Reference | 20.00 - array_repeat - 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.sql.DataFrameColumn.array_repeat = array_repeat(self, count, atype=None)
DESCRIPTION:
    Creates an array containing a column repeated count times.
 
PARAMETERS:
    count:
        Required Argument.
        Specifies the number of times to repeat each element.
        Note: 
            * If count is less than or equal to 0, an empty array is returned.
        Types: ColumnExpression OR int
 
    atype:
        Optional Argument.  
        Specifies the array data type of the resulting array.
        Note: 
            * If not specified, teradataml derives the type from the column type.
        Types: teradatasqlalchemy types object
 
RETURNS:
    ColumnExpression
 
EXAMPLES:
    # 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 an array column by repeating the values in column 'accounts' 3 times.
    >>> res = df.assign(repeated_arr = df.accounts.array_repeat(3))
    >>> res
                  Feb    Jan    Mar    Apr  datetime                              repeated_arr
    accounts                                                                                  
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04        ('Blue Inc','Blue Inc','Blue Inc')
    Red Inc     200.0  150.0  140.0    NaN  17/01/04           ('Red Inc','Red Inc','Red Inc')
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04  ('Yellow Inc','Yellow Inc','Yellow Inc')
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04     ('Jones LLC','Jones LLC','Jones LLC')
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04        ('Alpha Co','Alpha Co','Alpha Co')
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04  ('Orange Inc','Orange Inc','Orange Inc')
 
    # Example 2: Create an array column of type ARRAY_DECIMAL by repeating the values in column 
    #           'Jan' based on the value in column 'count'.
    >>> from teradatasqlalchemy.types import ARRAY_DECIMAL
    >>> tdf = df.assign(count_col = 2)
    >>> res = tdf.assign(repeated_arr = tdf.Jan.array_repeat(tdf.count_col, ARRAY_DECIMAL("[100]")))
    >>> res
                 Feb    Jan    Mar    Apr  datetime  count_col                                       repeated_arr
    accounts                                                                                                      
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04          2                                        (NULL,NULL)
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04          2  (150.0000000000000000000,150.0000000000000000000)
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04          2    (50.0000000000000000000,50.0000000000000000000)
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04          2  (200.0000000000000000000,200.0000000000000000000)
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04          2                                        (NULL,NULL)
    Red Inc     200.0  150.0  140.0    NaN  17/01/04          2  (150.0000000000000000000,150.0000000000000000000)
 
    >>> res.dtypes
    accounts        VARCHAR(length=20, charset='LATIN')
    Feb                                         FLOAT()
    Jan                                        BIGINT()
    Mar                                        BIGINT()
    Apr                                        BIGINT()
    datetime                                     DATE()
    count_col                                 INTEGER()
    repeated_arr                 ARRAY_DECIMAL('[100]')