Teradata Package for Python Function Reference | 20.00 - Array - 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.array.Array.__init__ = __init__(self, elements, atype=None, default_null=False)
- DESCRIPTION:
Creates the object of Array.
PARAMETERS:
elements:
Required Argument.
Specifies the elements of similar Teradata types or literal values or numpy arrays
to store in array.
Note:
* If an empty tuple is provided, the atype defaults to ARRAY_VARCHAR with scope 100.
Types: tuple
atype:
Optional Argument.
Specifies the Teradata type of the array elements.
If the argument is not specified, then teradataml infers the type
based on the first element of the array.
Types: teradatasqlalchemy.types
default_null:
Optional Argument.
Specifies whether the array type prepopulates the missing values
with NULL or not. When set to True, missing values are populated
with NULL values, otherwise are undefined.
Default Value: False
Types: bool
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
>>> from teradataml import Array, DataFrame
>>> from teradatasqlalchemy.types import ARRAY_INTEGER, ARRAY_FLOAT, ARRAY_NUMBER
>>> import datetime
# Set up DataFrame for examples.
>>> load_example_data("DataFrame", "sales")
>>> df = DataFrame("sales")
# Example 1: Creating an Array with literal values.
>>> Array((1, 2, 3))
Array [elements=(1, 2, 3), atype=ARRAY_INTEGER, default_null=False]
# Example 2: Creating an Array with DataFrame columns.
>>> array_cols = Array((df.Jan, df.Feb), atype=ARRAY_NUMBER('[1:2]'))
>>> print(array_cols.elements[0].name)
'Jan'
>>> array_cols.atype
ARRAY_NUMBER('[1:2]')
# Example 3: Creating an Array with both columns and literal values.
>>> array_mixed = Array((df.Jan, 100, df.Feb, 200), atype=ARRAY_NUMBER('[1:4]'))
>>> array_mixed.elements[1]
100
>>> print(len(array_mixed.elements))
4
# Example 4: Creating an Array to store DATE type values.
>>> arr_dates = Array((datetime.date(2024, 6, 20), datetime.date(2025, 6, 2)))
>>> print(arr_dates)
Array [elements=(datetime.date(2024, 6, 20), datetime.date(2025, 6, 2)), atype=ARRAY_DATE,
default_null=False]
# Example 5: Creating an Array with Timestamp type elements.
>>> from teradatasqlalchemy.types import ARRAY_TIMESTAMP
>>> arr_timestamp = Array(datetime.datetime(2024, 6, 20, 12, 0, 0), datetime.datetime(2025, 6, 2, 15, 30, 0)),
... atype=ARRAY_TIMESTAMP('[2]', timezone=True))
>>> print(arr_timestamp)
Array [elements=(datetime.datetime(2024, 6, 20, 12, 0), datetime.datetime(2025, 6, 2, 15, 30)),
atype=ARRAY_TIMESTAMP, default_null=False]
# Example 6: Creating an Array with numpy arrays as elements.
>>> import numpy as np
>>> arr_numpy = Array((np.array([1, 2, 3]), np.array([4, 5, 6])))
>>> print(arr_numpy)
Array [elements=(array([1, 2, 3]), array([4, 5, 6])), atype=ARRAY_INTEGER, default_null=False]