Teradata Package for Python Function Reference on VantageCloud Lake - from_dict - 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.08
Published
November 2025
ft:locale
en-US
ft:lastEdition
2025-12-05
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.dataframe.dataframe.DataFrame.from_dict = from_dict(data, columns=None) method of builtins.type instance
DESCRIPTION:
    Creates a DataFrame from a dictionary containing values as lists or numpy arrays.
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the Python dictionary to create a teradataml DataFrame.
        Notes:
            * Keys of the dictionary are used as column names.
            * Values of the dictionary should be lists or numpy arrays.
            * Nested dictionaries are not supported.
        Types: dict
 
    columns:
        Optional Argument.
        Specifies the column names for the DataFrame.
        Types: str OR list of str
 
RETURNS:
    teradataml DataFrame
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> from teradataml import DataFrame
    >>> data_dict = {"name": ["Alice", "Bob", "Charlie"], "age": [25, 30, 28]}
 
    # Example 1: Create a teradataml DataFrame from a dictionary where 
    #            keys are column names and values are lists of column data.
    >>> df = DataFrame.from_dict(data_dict)
    >>> df
          name  age
    0  Charlie   28
    1      Bob   30
    2    Alice   25
 
    # Example 2: Create a teradataml DataFrame from a dictionary where
    #            keys are column names and values are numpy arrays.
    >>> import numpy as np
    >>> data_dict = {"col1": np.array([1, 2, 3]), "col2": np.array([4, 5, 6])}
    >>> df = DataFrame.from_dict(data_dict)
    >>> df
       col1  col2
    0     3     6
    1     2     5
    2     1     4