materialize() | DataFrames | Teradata Python Package - materialize() - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

Use materialize() function to persist a teradataml dataframe, created for lazy operations on a teradataml DataFrame, into a database for the current session, in the form of a view.

Example Setup

>>> load_example_data("dataframe", "admissions_train")
>>> df = DataFrame("admissions_train")
>>> df
   masters   gpa     stats programming  admitted
id
13      no  4.00  Advanced      Novice         1
26     yes  3.57  Advanced    Advanced         1
5       no  3.44    Novice      Novice         0
19     yes  1.98  Advanced    Advanced         0
15     yes  4.00  Advanced    Advanced         1
40     yes  3.95    Novice    Beginner         0
7      yes  2.33    Novice      Novice         1
22     yes  3.46    Novice    Beginner         0
36      no  3.00  Advanced      Novice         0
38     yes  2.65  Advanced    Beginner         1

Example 1: Perform lazy DataFrame operation and manually materialize the view

>>> df2 = df.get([["id", "masters", "gpa"]])

Initially, the table name will be None.

>>> df2._table_name
>>> df2.materialize()
   masters   gpa
id
15     yes  4.00
7      yes  2.33
22     yes  3.46
17      no  3.83
13      no  4.00
38     yes  2.65
26     yes  3.57
5       no  3.44
34     yes  3.85
40     yes  3.95

After materialize(), view name will be assigned.

>>> df2._table_name
'"ALICE"."ml__select__172077355985236"'
>>>