Teradata Package for Python Function Reference on VantageCloud Lake - element_state - 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
Published
August 2026
ft:locale
en-US
ft:lastEdition
2026-08-13
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.element_state = element_state(self, index)
DESCRIPTION:
    Check whether the element at the specified index in the array is initialized or not.
 
PARAMETERS:
    index:
        Required Argument.
        Specifies the index of the array element to be checked.
        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')
 
    # Example 1: Check if element at index 2 in array column 'arr2' is initialized.
    >>> res = df.assign(element_2_state = df.arr2.element_state(2))
    >>> res
                     arr1                   arr2                        arr3  element_2_state
    id                                                                                        
    1    (10,20,30,40,50)     (23,200,215,40,21)  ('ab','bc','cd','ab','ef')                1
    4   (180,28,38,48,58)  (30,NULL,NULL,250,27)  ('mn','no',NULL,'op','pq')                1
    2   (150,25,35,45,55)       (28,50,95,90,26)  ('xy','yz','za','ab','xy')                1
    6   (16,261,36,46,56)     (29,170,160,46,25)  ('uv','xy','ab','xy','yz')                1
    3   (12,22,320,42,52)     (25,22,140,200,23)  ('pq','ab','ab','st','tu')                1
    5    (14,24,34,44,54)  (26,NULL,NULL,180,24)  ('ij','jk',NULL,'kl','lm')                1
 
    # Example 2: Check if element at index 6 in array column 'arr2' is initialized.
    >>> res = df.assign(element_6_state = df.arr2.element_state(6))
    >>> res
                     arr1                   arr2                        arr3  element_2_state
    id                                                                                       
    1    (10,20,30,40,50)     (23,200,215,40,21)  ('ab','bc','cd','ab','ef')                0
    4   (180,28,38,48,58)  (30,NULL,NULL,250,27)  ('mn','no',NULL,'op','pq')                0
    2   (150,25,35,45,55)       (28,50,95,90,26)  ('xy','yz','za','ab','xy')                0
    6   (16,261,36,46,56)     (29,170,160,46,25)  ('uv','xy','ab','xy','yz')                0
    3   (12,22,320,42,52)     (25,22,140,200,23)  ('pq','ab','ab','st','tu')                0
    5    (14,24,34,44,54)  (26,NULL,NULL,180,24)  ('ij','jk',NULL,'kl','lm')                0
 
    # Example 3: Create a array column with initialized elements with default_null=True
    #            and check the element state at index 6. 
    >>> sdf = df.assign(arr2=Array((df.id,20,30), atype=ARRAY_INTEGER('[7]' , default_null=True)))
    >>> res = sdf.assign(element_6_state = sdf.arr2.element_state(6))
    >>> res
                     arr1                           arr2                        arr3  element_6_state
    id                                                                                               
    1    (10,20,30,40,50)  (1,20,30,NULL,NULL,NULL,NULL)  ('ab','bc','cd','ab','ef')                1
    4   (180,28,38,48,58)  (4,20,30,NULL,NULL,NULL,NULL)  ('mn','no',NULL,'op','pq')                1
    2   (150,25,35,45,55)  (2,20,30,NULL,NULL,NULL,NULL)  ('xy','yz','za','ab','xy')                1
    6   (16,261,36,46,56)  (6,20,30,NULL,NULL,NULL,NULL)  ('uv','xy','ab','xy','yz')                1
    3   (12,22,320,42,52)  (3,20,30,NULL,NULL,NULL,NULL)  ('pq','ab','ab','st','tu')                1
    5    (14,24,34,44,54)  (5,20,30,NULL,NULL,NULL,NULL)  ('ij','jk',NULL,'kl','lm')                1