from_query() | FeatureGroup Method | Teradata Package for Python - from_query() - Teradata Package for Python

Teradata® Package for Python User Guide

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

Use the from_query() method to create a feature group from a query.

Required Parameters

name
Specifies the name of the feature group.

Entity and DataSource also get the same name as name.

You can change the name of entity or data source by accessing the object from the feature group.

entity_columns
Specifies the entity columns.
query
Specifies the column names for the entity.

Optional Parameter

timestamp_column
Specifies the name of the column in the query that contains the record creation time.

Example setup

>>> load_example_data('dataframe', ['sales'])
>>> df = DataFrame("sales")

Example 1: Create a FeatureGroup from query 'SELECT * FROM SALES' and consider 'accounts' column as entity and 'datetime' column as timestamp_column

>>> from teradataml import FeatureGroup
>>> query = 'SELECT * FROM SALES'
>>> fg = FeatureGroup.from_query(
...             name='sales',
...             entity_columns='accounts',
...             query=query,
...             timestamp_column='datetime'
...         )

Example 2: Create a FeatureGroup from query 'SELECT * FROM SALES' and consider 'accounts' and 'jan' columns as entity and 'datetime' column as timestamp_column. Here, timestamp_column is specified as ColumnExpression

>>> from teradataml import FeatureGroup, ColumnExpression
>>> query = 'SELECT * FROM SALES'
>>> fg = FeatureGroup.from_query(
...             name='sales',
...             entity_columns=['accounts', 'jan'],
...             query=query,
...             timestamp_column=df.datetime)