Use the from_DataFrame() method to create a feature group from a DataFrame.
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 column names for the entity.
- df
- Specifies teradataml DataFrame for creating the data source.
Optional Parameter
- timestamp_column
- Specifies the timestamp column.
Example setup
>>> load_example_data('dataframe', ['sales'])
>>> df = DataFrame("sales")
Example 1: create a FeatureGroup from DataFrame created on 'sales' table and consider 'accounts' column as entity and 'datetime' column as timestamp_column
>>> from teradataml import FeatureGroup
>>> df = DataFrame("sales")
>>> fg = FeatureGroup.from_DataFrame(
... name='sales',
... entity_columns='accounts',
... df=df,
... timestamp_column='datetime'
... )
Print the feature group.
>>> fg
FeatureGroup(sales, features=[Feature(name=Feb), Feature(name=Jan), Feature(name=Mar), Feature(name=Apr)], entity=Entity(name=sales), data_source=DataSource(name=sales))
Example 2: create a FeatureGroup from DataFrame created on 'sales' table 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
>>> fg = FeatureGroup.from_DataFrame( ... name='sales', ... entity_columns=['accounts', 'jan'], ... df=df, ... timestamp_column=df.datetime ... )
Print the feature group.
>>> fg
FeatureGroup(sales, features=[Feature(name=Feb), Feature(name=Jan), Feature(name=Mar), Feature(name=Apr)], entity=Entity(name=sales), data_source=DataSource(name=sales))