Teradata Package for Python Function Reference on VantageCloud Lake - array_size - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
20.00.00.11
Publication Date
August 2026
Content Type
Programming Reference
Publication ID
B700-4500-200K
ft:locale
en-US
ft:lastEdition
2026-08-13
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.array_size = array_size(self, lower_bound=None, upper_bound=None)
DESCRIPTION:
    Get the size of the array.
    Note:
        * The function does not consider uninitialized elements in the array.
          For example, if scope of the array is 5 and only 3 elements are initialized,
          the size returns 3.
 
PARAMETERS:
    lower_bound:
        Optional Argument.
        Specifies the lower bound value to start counting for the elements.
        Note:
            * If specified, both "lower_bound" and "upper_bound" arguments must be provided.
        Types: int
 
    upper_bound:
        Optional Argument.
        Specifies the upper bound value to end the counting for the elements.
        Note:
            * If specified, both "lower_bound" and "upper_bound" arguments must be provided.
        Types: int
 
RETURNS:
    ColumnExpression
 
EXAMPLES:
    >>> from teradataml import *
    >>> load_example_data("array", "array_table")
 
    # Create a DataFrame on 'array_table'.
    >>> df = DataFrame("array_table")
    >>> df
                     arr1                   arr2                        arr3
    id                                                                      
    1    (10,20,30,40,50)     (23,200,215,40,21)  ('ab','bc','cd','ab','ef')
    4   (180,28,38,48,58)  (30,NULL,NULL,250,27)  ('mn','no',NULL,'op','pq')
    2   (150,25,35,45,55)       (28,50,95,90,26)  ('xy','yz','za','ab','xy')
    6   (16,261,36,46,56)     (29,170,160,46,25)  ('uv','xy','ab','xy','yz')
    3   (12,22,320,42,52)     (25,22,140,200,23)  ('pq','ab','ab','st','tu')
    5    (14,24,34,44,54)  (26,NULL,NULL,180,24)  ('ij','jk',NULL,'kl','lm')
 
    >>> df.tdtypes
    id                              INTEGER()
    arr1              ARRAY_INTEGER('[1:10]')
    arr2              ARRAY_INTEGER('[1:10]')
    arr3    ARRAY_VARCHAR('[1:10]', length=4)
 
    # Example 1: Get the size of array column 'arr1'.
    >>> res = df.assign(arr1_size = df.arr1.array_size())
    >>> res
                     arr1                   arr2                        arr3  arr1_size
    id                                                                                  
    1    (10,20,30,40,50)     (23,200,215,40,21)  ('ab','bc','cd','ab','ef')          5
    4   (180,28,38,48,58)  (30,NULL,NULL,250,27)  ('mn','no',NULL,'op','pq')          5
    2   (150,25,35,45,55)       (28,50,95,90,26)  ('xy','yz','za','ab','xy')          5
    6   (16,261,36,46,56)     (29,170,160,46,25)  ('uv','xy','ab','xy','yz')          5
    3   (12,22,320,42,52)     (25,22,140,200,23)  ('pq','ab','ab','st','tu')          5
    5    (14,24,34,44,54)  (26,NULL,NULL,180,24)  ('ij','jk',NULL,'kl','lm')          5
 
    # Example 2: Get the size of the array column 'arr1' with initialized elements.
    >>> sdf = df.assign(arr1=Array((23, df.id, 5), atype=ARRAY_INTEGER('[5]', default_null=True)))
    >>> res = sdf.assign(arr1_size = sdf.arr1.array_size())
    >>> res
                     arr1                   arr2                        arr3   arr1_size
    id                                                                                  
    1   (23,1,5,NULL,NULL)     (23,200,215,40,21)  ('ab','bc','cd','ab','ef')          5
    4   (23,4,5,NULL,NULL)  (30,NULL,NULL,250,27)  ('mn','no',NULL,'op','pq')          5
    2   (23,2,5,NULL,NULL)       (28,50,95,90,26)  ('xy','yz','za','ab','xy')          5
    6   (23,6,5,NULL,NULL)     (29,170,160,46,25)  ('uv','xy','ab','xy','yz')          5
    3   (23,3,5,NULL,NULL)     (25,22,140,200,23)  ('pq','ab','ab','st','tu')          5
    5   (23,5,5,NULL,NULL)  (26,NULL,NULL,180,24)  ('ij','jk',NULL,'kl','lm')          5
 
    # Example 3: Get the size of elements in array column 'arr2' from second position to fourth position.
    >>> res = df.assign(arr1_size = df.arr1.array_size(lower_bound=2, upper_bound=4))
    >>> res
                    arr1                   arr2                        arr3   arr1_size
    id                                                                                 
    1    (10,20,30,40,50)     (23,200,215,40,21)  ('ab','bc','cd','ab','ef')          3
    4   (180,28,38,48,58)  (30,NULL,NULL,250,27)  ('mn','no',NULL,'op','pq')          3
    2   (150,25,35,45,55)       (28,50,95,90,26)  ('xy','yz','za','ab','xy')          3
    6   (16,261,36,46,56)     (29,170,160,46,25)  ('uv','xy','ab','xy','yz')          3
    3   (12,22,320,42,52)     (25,22,140,200,23)  ('pq','ab','ab','st','tu')          3
    5    (14,24,34,44,54)  (26,NULL,NULL,180,24)  ('ij','jk',NULL,'kl','lm')          3