Teradata Package for Python Function Reference on VantageCloud Lake - extract - 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.extract = extract(self, value, timezone=None)
DESCRIPTION:
    Extracts a single specified field from any DateTime, Interval or timestamp value,
    converting it to an exact numeric value.
 
PARAMETERS:
    value:
        Required Argument.
        Specifies the field which needs to be extracted.
        Permitted Values: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, TIMEZONE_HOUR, TIMEZONE_MINUTE
        Note:
            * Permitted Values are case insensitive.
        Type: str
 
    timezone:
        Optional Argument.
        Specifies the timezone string.
        For valid timezone strings, user should check Vantage documentation.
        Type: ColumnExpression or str.
 
RETURNS:
    ColumnExpression
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("uaf", "Traindata")
 
    # Create a DataFrame on 'Traindata' table.
 
    >>> temp_df = DataFrame("Traindata")
    >>> df = temp_df.select(["seq_no", "schedule_date", "arrivalTime"])
    >>> df
            schedule_date          arrivalTime
    seq_no
    26          16/03/26  2016-03-26 12:33:05
    24          16/03/26  2016-03-26 12:25:06
    3           16/03/26  2016-03-26 10:52:05
    22          16/03/26  2016-03-26 12:18:01
    20          16/03/26  2016-03-26 12:10:06
    18          16/03/26  2016-03-26 12:04:01
    8           16/03/26  2016-03-26 11:15:06
    17          16/03/26  2016-03-26 11:56:06
    15          16/03/26  2016-03-26 11:45:00
    13          16/03/26  2016-03-26 11:33:00
    11          16/03/26  2016-03-26 11:26:00
 
    # Example 1: Extract year from column 'schedule_date'.
    >>> df.assign(col = df.schedule_date.extract('YEAR'))
            schedule_date          arrivalTime   col
    seq_no
    26          16/03/26  2016-03-26 12:33:05  2016
    24          16/03/26  2016-03-26 12:25:06  2016
    3           16/03/26  2016-03-26 10:52:05  2016
    22          16/03/26  2016-03-26 12:18:01  2016
    20          16/03/26  2016-03-26 12:10:06  2016
    18          16/03/26  2016-03-26 12:04:01  2016
    8           16/03/26  2016-03-26 11:15:06  2016
    17          16/03/26  2016-03-26 11:56:06  2016
    15          16/03/26  2016-03-26 11:45:00  2016
    13          16/03/26  2016-03-26 11:33:00  2016
    11          16/03/26  2016-03-26 11:26:00  2016
 
    # Example 2: Extract hour from column 'arrivalTime'.
    >>> df.assign(col = df.arrivalTime.extract('HOUR'))
            schedule_date          arrivalTime col
    seq_no
    26          16/03/26  2016-03-26 12:33:05  12
    24          16/03/26  2016-03-26 12:25:06  12
    3           16/03/26  2016-03-26 10:52:05  10
    22          16/03/26  2016-03-26 12:18:01  12
    20          16/03/26  2016-03-26 12:10:06  12
    18          16/03/26  2016-03-26 12:04:01  12
    8           16/03/26  2016-03-26 11:15:06  11
    17          16/03/26  2016-03-26 11:56:06  11
    15          16/03/26  2016-03-26 11:45:00  11
 
    # Example 3: Extract hour from column 'arrivalTime' with offset '-11:00'.
    >>> df.assign(col = df.arrivalTime.extract('HOUR', '-11:00'))
            schedule_date          arrivalTime col
    seq_no
    26          16/03/26  2016-03-26 12:33:05   1
    24          16/03/26  2016-03-26 12:25:06   1
    3           16/03/26  2016-03-26 10:52:05  23
    22          16/03/26  2016-03-26 12:18:01   1
    20          16/03/26  2016-03-26 12:10:06   1
    18          16/03/26  2016-03-26 12:04:01   1
    8           16/03/26  2016-03-26 11:15:06   0
    17          16/03/26  2016-03-26 11:56:06   0
    15          16/03/26  2016-03-26 11:45:00   0
 
    # Example 4: Extract hour from column 'arrivalTime' with offset 10.
    >>> df.assign(col = df.arrivalTime.extract('HOUR', 10))
            schedule_date          arrivalTime col
    seq_no
    26          16/03/26  2016-03-26 12:33:05  22
    24          16/03/26  2016-03-26 12:25:06  22
    3           16/03/26  2016-03-26 10:52:05  20
    22          16/03/26  2016-03-26 12:18:01  22
    20          16/03/26  2016-03-26 12:10:06  22
    18          16/03/26  2016-03-26 12:04:01  22
    8           16/03/26  2016-03-26 11:15:06  21
    17          16/03/26  2016-03-26 11:56:06  21
    15          16/03/26  2016-03-26 11:45:00  21
    13          16/03/26  2016-03-26 11:33:00  21
    11          16/03/26  2016-03-26 11:26:00  21