TeradataML

20.0.0.10 · active · verified Wed Apr 15

teradataml is a Python package that provides an interface to perform advanced analytics on Teradata Vantage. It allows users to leverage the massive parallel processing capabilities of Teradata Vantage for data manipulation, transformation, and various analytic functions without extensive SQL coding. The current version is 20.0.0.10, and it receives frequent minor updates within its major releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish a connection to Teradata Vantage using `create_context`, create a teradataml DataFrame from an existing table, and display its head. It uses environment variables for sensitive connection details.

import os
from teradataml import create_context, DataFrame, remove_context

host = os.environ.get('TD_HOST', 'your_teradata_host')
username = os.environ.get('TD_USERNAME', 'your_username')
password = os.environ.get('TD_PASSWORD', 'your_password')
temp_database_name = os.environ.get('TD_TEMP_DB', 'your_temp_db')

# Establish connection to Teradata Vantage
try:
    create_context(host=host, username=username, password=password, 
                   logmech='TD2', temp_database_name=temp_database_name)
    print("Successfully connected to Teradata Vantage.")

    # Create a teradataml DataFrame from an existing table
    # Replace 'your_table_name' and 'your_database' with actual values
    # For demo, assuming a table named 'sample_data' in the default database
    td_df = DataFrame(tablename='sample_data')
    print("\nTeradataml DataFrame head:")
    print(td_df.head())

except Exception as e:
    print(f"An error occurred: {e}")
finally:
    # Clean up the connection
    if create_context._active_context:
        remove_context()
        print("Connection context removed.")

view raw JSON →