Teradata Package for Python Function Reference on VantageCloud Lake - parse_url - 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.parse_url = parse_url(self, url_part, key=None)
DESCRIPTION:
    Extracts a specific part from the URL.
 
PARAMETERS:
    url_part:
        Required Argument.
        Specifies which part to be extracted.
        Permitted Values: HOST, PATH, QUERY, REF, PROTOCOL, FILE, AUTHORITY, USERINFO
        Type: str or ColumnExpression
 
    key:
        Optional Argument.
        Specifies the key to be used for extracting the value from the query string.
        Note:
            * Applicable only when url_part is set to 'QUERY'.
        Type: str or ColumnExpression
 
Returns:
    ColumnExpression
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("teradataml", "url_data")
 
    # Create a DataFrame on 'url_data' table.
    >>> df = DataFrame("url_data")
    >>> df
                                                                urls       part     query_key
    id                                                                                       
    3                                       https://www.facebook.com       HOST  facebook.com
    8             http://example.com/api?query1=value1&query2=value2      QUERY        query1
    6              smtp://user:password@smtp.example.com:21/file.txt   USERINFO      password
    4   https://teracloud-pod-services-pod-account-service.dummyvalu      QUERY          None
    0                                   http://example.com:8080/path       FILE          path
    2   https://example.net/path4/path5/path6?query4=value4#fragment        REF     fragment3
    1                                      ftp://example.net:21/path       PATH          path
    5                        http://pg.example.ml/path150#fragment90  AUTHORITY    fragment90
    7                                         https://www.google.com   PROTOCOL    google.com
 
    # Example 1: Extract components from column 'urls' using column 'part'.
    >>> df.assign(col = df.urls.parse_url(df.part))
                                                                urls       part     query_key                          col
    id                                                                                                                    
    3                                       https://www.facebook.com       HOST  facebook.com             www.facebook.com
    8             http://example.com/api?query1=value1&query2=value2      QUERY        query1  query1=value1&query2=value2
    6              smtp://user:password@smtp.example.com:21/file.txt   USERINFO      password                user:password
    4   https://teracloud-pod-services-pod-account-service.dummyvalu      QUERY          None                         None
    0                                   http://example.com:8080/path       FILE          path                        /path
    2   https://example.net/path4/path5/path6?query4=value4#fragment        REF     fragment3                     fragment
    1                                      ftp://example.net:21/path       PATH          path                        /path
    5                        http://pg.example.ml/path150#fragment90  AUTHORITY    fragment90                pg.example.ml
    7                                         https://www.google.com   PROTOCOL    google.com                        https
    
    # Example 2: Extract components from column 'urls' using 'part' and
    #            'query_key' column.
    >>> df.assign(col = df.urls.parse_url(df.part, df.query_key))
                                                                urls       part     query_key     col
    id                                                                                               
    3                                       https://www.facebook.com       HOST  facebook.com    None
    8             http://example.com/api?query1=value1&query2=value2      QUERY        query1  value1
    6              smtp://user:password@smtp.example.com:21/file.txt   USERINFO      password    None
    4   https://teracloud-pod-services-pod-account-service.dummyvalu      QUERY          None    None
    0                                   http://example.com:8080/path       FILE          path    None
    2   https://example.net/path4/path5/path6?query4=value4#fragment        REF     fragment3    None
    1                                      ftp://example.net:21/path       PATH          path    None
    5                        http://pg.example.ml/path150#fragment90  AUTHORITY    fragment90    None
    7                                         https://www.google.com   PROTOCOL    google.com    None
 
    # Extract components from column 'urls' using 'part' and 'query_key' str.
    >>> df.assign(col = df.urls.parse_url('QUERY', 'query2'))
                                                                urls       part     query_key     col
    id                                                                                               
    3                                       https://www.facebook.com       HOST  facebook.com    None
    8             http://example.com/api?query1=value1&query2=value2      QUERY        query1  value2
    6              smtp://user:password@smtp.example.com:21/file.txt   USERINFO      password    None
    4   https://teracloud-pod-services-pod-account-service.dummyvalu      QUERY          None    None
    0                                   http://example.com:8080/path       FILE          path    None
    2   https://example.net/path4/path5/path6?query4=value4#fragment        REF     fragment3    None
    1                                      ftp://example.net:21/path       PATH          path    None
    5                        http://pg.example.ml/path150#fragment90  AUTHORITY    fragment90    None
    7                                         https://www.google.com   PROTOCOL    google.com    None