Teradata Package for Python Function Reference | 20.00 - __init__ - 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.dataframe.DataFrame.__init__ = __init__(self, data=None, index=True, index_label=None, query=None, materialize=False, **kwargs)
- Constructor for teradataml DataFrame.
PARAMETERS:
data:
Optional Argument.
Specifies the input data to create a teradataml DataFrame.
Notes:
* If a dictionary is provided, it must follow the below requirements:
* Keys must be strings (column names).
* Values must be lists of equal length (column data).
* Nested dictionaries are not supported.
* If the first row of an array column contains an empty list,
the column type defaults to ARRAY_VARCHAR with scope 100.
Types: str OR pandas DataFrame OR in_schema OR numpy array OR list OR dictionary
index:
Optional Argument.
If "data" is a string, then the argument specifies whether to use the index column
for sorting or not.
If "data" is a pandas DataFrame, then this argument specifies whether to
save Pandas DataFrame index as a column or not.
Default Value: True
Types: bool
index_label:
Optional Argument.
If "data" is a string, then the argument specifies column(s) used for sorting.
If "data" is a pandas DataFrame, then the default behavior is applied.
Note:
* Refer to the "index_label" parameter of copy_to_sql() for details on the default behaviour.
Types: str OR list of str
query:
Optional Argument.
SQL query for this Dataframe. Used by class method from_query.
Types: str
materialize:
Optional Argument.
Whether to materialize DataFrame or not when created.
Used by class method from_query.
You should use materialization, when the query passed to from_query(),
is expected to produce non-deterministic results, when it is executed multiple
times. Using this option will help user to have deterministic results in the
resulting teradataml DataFrame.
Default Value: False (No materialization)
Types: bool
kwargs:
table_name:
Optional Argument.
The table name or view name in Teradata Vantage referenced by this DataFrame.
Note:
* If "data" and "table_name" are both specified, then the "table_name" argument is ignored.
Types: str or in_schema
primary_index:
Optional Argument.
Specifies which column(s) to use as primary index for the teradataml DataFrame.
Note:
* This argument is only applicable when creating a DataFrame from a pandas DataFrame.
Types: str OR list of str
types:
Optional Argument.
Specifies required data types for requested columns to be saved in Teradata Vantage.
Notes:
* This argument is not applicable when "data" argument is of type str or in_schema.
* Refer to the "types" parameter of copy_to_sql() for more details.
Types: dict
columns:
Optional Argument.
Specifies the names of the columns to be used in the DataFrame.
Notes:
* This argument is not applicable when "data" argument is of type str or in_schema.
* If "data" is a dictionary and this argument is specified, only the specified columns will be
included in the DataFrame if the dictionary contains those keys. If the dictionary does not
contain the specified keys, those columns will be added with NaN values.
Types: str OR list of str
persist:
Optional Argument.
Specifies whether to persist the DataFrame.
Note:
* This argument is only applicable when the "data" argument is of type dict, list or
pandas DataFrame.
Default Value: False
Types: bool
EXAMPLES:
>>> from teradataml.dataframe.dataframe import DataFrame
>>> import pandas as pd
# Example 1: Create a teradataml DataFrame from table name.
>>> df = DataFrame("mytab")
# Example 2: Create a teradataml DataFrame from view name.
>>> df = DataFrame("myview")
# Example 3: Create a teradataml DataFrame using view name without using index column for sorting.
>>> df = DataFrame("myview", False)
# Example 4: Create a teradataml DataFrame using table name and consider columns Col1 and Col2
# while running DataFrame.head() or DataFrame.tail() methods.
>>> df = DataFrame("mytab", True, ["Col1", "Col2"])
# Example 5: Create a teradataml DataFrame from the existing Vantage table "dbcinfo"
# in the non-default database "dbc" using the in_schema() object.
>>> from teradataml.dataframe.dataframe import in_schema
>>> df = DataFrame(in_schema("dbc", "dbcinfo"))
# Example 6: Create a teradataml DataFrame from a pandas DataFrame.
>>> pdf = pd.DataFrame({"col1": [1, 2, 3], "col2": [4, 5, 6]})
>>> df = DataFrame(pdf)
>>> df
col1 col2 index_label
0 3 6 2
1 2 5 1
2 1 4 0
# Example 7: Create a teradataml DataFrame from a pandas DataFrame without index column.
>>> pdf = pd.DataFrame({"col1": [1, 2, 3], "col2": [4, 5, 6]})
>>> df = DataFrame(data=pdf, index=False)
>>> df
col1 col2
0 3 6
1 2 5
2 1 4
# Example 8: Create a teradataml DataFrame from a pandas DataFrame with
# index label and primary index as 'id'.
>>> pdf = pd.DataFrame({"col1": [1, 2, 3], "col2": [4, 5, 6]})
>>> df = DataFrame(pdf, index=True, index_label='id', primary_index='id')
>>> df
col1 col2
id
2 3 6
1 2 5
0 1 4
# Example 9: Create a teradataml DataFrame from list of lists.
>>> df = DataFrame([[1, 2], [3, 4]])
>>> df
col_0 col_1 index_label
0 3 4 1
1 1 2 0
# Example 10: Create a teradataml DataFrame from numpy array.
>>> import numpy as np
>>> df = DataFrame(np.array([[1, 2], [3, 4]]), index=True, index_label="id")
>>> df
col_0 col_1
id
1 3 4
0 1 2
# Example 11: Create a teradataml DataFrame from a dictionary.
>>> df = DataFrame({"col1": [1, 2], "col2": [3, 4]}, index=True, index_label="id")
>>> df
col1 col2
id
1 2 4
0 1 3
# Example 12: Create a teradataml DataFrame from list of dictionaries.
>>> df = DataFrame([{"col1": 1, "col2": 2}, {"col1": 3, "col2": 4}], index=False)
>>> df
col1 col2
0 3 4
1 1 2
# Example 13: Create a teradataml DataFrame from list of tuples.
>>> df = DataFrame([("Alice", 1), ("Bob", 2)])
>>> df
col_0 col_1 index_label
0 Alice 1 1
1 Bob 2 0
# Example 14: Create a teradataml DataFrame from a numpy arrays.
>>> import numpy as np
>>> pdf = pd.DataFrame({
... 'id': [1, 2],
... 'values': [np.array([1, 2, 3]), np.array([4, 5, 6])],
... 'tags': [np.array(['a', 'b', 'c']), np.array(['x', 'y', 'z'])]
... })
>>> df = DataFrame(pdf)
>>> df
id values tags index_label
0 2 (4,5,6) ('x','y','z') 1
1 1 (1,2,3) ('a','b','c') 0
RAISES:
TeradataMlException - TDMLDF_CREATE_FAIL