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)