Teradata Package for Python Function Reference | 20.00 - array_compare - 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_compare = array_compare(self, other, lower_bound=None, upper_bound=None, nulls_equal=False)
- DESCRIPTION:
Compare the elements of the array with another array.
PARAMETERS:
other:
Required Argument.
Specifies the array to compare against.
Types: ColumnExpression
lower_bound:
Optional Argument.
Specifies the starting index for comparison (inclusive).
Note:
* If specified, both "lower_bound" and "upper_bound" arguments must be provided.
Types: int
upper_bound:
Optional Argument.
Specifies the ending index for comparison (inclusive).
Note:
* If specified, both "lower_bound" and "upper_bound" arguments must be provided.
Types: int
nulls_equal:
Optional Argument.
Specifies whether NULL values should be considered equal during comparison.
Default Value: False
Types: bool
RETURNS:
ColumnExpression
EXAMPLES:
>>> from teradataml import *
>>> load_example_data("dataframe", "sales")
# Create a DataFrame on 'sales' table and assign two array columns.
>>> tdf = DataFrame('sales')
>>> df = tdf.assign(arr1=Array((10,20,30,40,50)), arr2=Array((23,tdf.Jan,tdf.Mar,tdf.Feb,21)))
>>> df
Feb Jan Mar Apr datetime arr1 arr2
accounts
Alpha Co 210.0 200.0 215.0 250.0 04/01/2017 (10,20,30,40,50) (23,200,215,210,21)
Blue Inc 90.0 50.0 95.0 101.0 04/01/2017 (10,20,30,40,50) (23,50,95,90,21)
Jones LLC 200.0 150.0 140.0 180.0 04/01/2017 (10,20,30,40,50) (23,150,140,200,21)
Orange Inc 210.0 NaN NaN 250.0 04/01/2017 (10,20,30,40,50) (23,NULL,NULL,210,21)
Yellow Inc 90.0 NaN NaN NaN 04/01/2017 (10,20,30,40,50) (23,NULL,NULL,90,21)
Red Inc 200.0 150.0 140.0 NaN 04/01/2017 (10,20,30,40,50) (23,150,140,200,21)
# Example 1: Compare two array columns 'arr1' and 'arr2' if they are equal or not.
>>> res = df.assign(compare_res = df.arr1.array_compare(df.arr2))
>>> res
Feb Jan Mar Apr datetime arr1 arr2 compare_res
accounts
Alpha Co 210.0 200.0 215.0 250.0 04/01/2017 (10,20,30,40,50) (23,200,215,210,21) 0
Blue Inc 90.0 50.0 95.0 101.0 04/01/2017 (10,20,30,40,50) (23,50,95,90,21) 0
Jones LLC 200.0 150.0 140.0 180.0 04/01/2017 (10,20,30,40,50) (23,150,140,200,21) 0
Orange Inc 210.0 NaN NaN 250.0 04/01/2017 (10,20,30,40,50) (23,NULL,NULL,210,21) 0
Yellow Inc 90.0 NaN NaN NaN 04/01/2017 (10,20,30,40,50) (23,NULL,NULL,90,21) 0
Red Inc 200.0 150.0 140.0 NaN 04/01/2017 (10,20,30,40,50) (23,150,140,200,21) 0
# Example 2: Compare if two array columns 'arr1' and 'arr2' are equal or not for the
# elements present in second position to fifth position in the array.
>>> df = tdf.assign(arr1=Array((23,tdf.Jan,tdf.Mar,tdf.Feb,21)), arr2=Array((23,tdf.Jan,tdf.Mar,tdf.Feb,21)))
>>> res = df.assign(compare_res = df.arr1.array_compare(df.arr2, lower_bound=2, upper_bound=5))
>>> res
Feb Jan Mar Apr datetime arr1 arr2 compare_res
accounts
Alpha Co 210.0 200.0 215.0 250.0 04/01/2017 (23,200,215,210,21) (23,200,215,210,21) 1.0
Blue Inc 90.0 50.0 95.0 101.0 04/01/2017 (23,50,95,90,21) (23,50,95,90,21) 1.0
Jones LLC 200.0 150.0 140.0 180.0 04/01/2017 (23,150,140,200,21) (23,150,140,200,21) 1.0
Orange Inc 210.0 NaN NaN 250.0 04/01/2017 (23,NULL,NULL,210,21) (23,NULL,NULL,210,21) NaN
Yellow Inc 90.0 NaN NaN NaN 04/01/2017 (23,NULL,NULL,90,21) (23,NULL,NULL,90,21) NaN
Red Inc 200.0 150.0 140.0 NaN 04/01/2017 (23,150,140,200,21) (23,150,140,200,21) 1.0
>>>
# Example 3: Compare if two array columns 'arr1' and 'arr2' are equal or not for the
# elements present in second position to fifth position in the array with NULLs
# considered equal using 'nulls_equal' argument.
>>> res = df.assign(compare_res = df.arr1.array_compare(df.arr2, lower_bound=2, upper_bound=5, nulls_equal=True))
>>> res
Feb Jan Mar Apr datetime arr1 arr2 compare_res
accounts
Alpha Co 210.0 200.0 215.0 250.0 04/01/2017 (23,200,215,210,21) (23,200,215,210,21) 1
Blue Inc 90.0 50.0 95.0 101.0 04/01/2017 (23,50,95,90,21) (23,50,95,90,21) 1
Jones LLC 200.0 150.0 140.0 180.0 04/01/2017 (23,150,140,200,21) (23,150,140,200,21) 1
Orange Inc 210.0 NaN NaN 250.0 04/01/2017 (23,NULL,NULL,210,21) (23,NULL,NULL,210,21) 1
Yellow Inc 90.0 NaN NaN NaN 04/01/2017 (23,NULL,NULL,90,21) (23,NULL,NULL,90,21) 1
Red Inc 200.0 150.0 140.0 NaN 04/01/2017 (23,150,140,200,21) (23,150,140,200,21) 1