pip install featuretools import featuretools as ft★Addfeaturetools[dask]/[spark]for distributed compute.# DFS = aggregation primitives (across relationships) # + transform primitives (within a row/table), stacked★The mental model: aggregations summarize child rows up to a parent (a customer'sMEAN(transactions.amount)); transforms derive within a table (MONTH(timestamp)).es = ft.demo.load_mock_customer(return_entityset=True)A ready-made multi-table EntitySet for experimenting.
es = ft.EntitySet(id="shop")★The container that holds your tables and their relationships.es = es.add_dataframe( dataframe_name="transactions", dataframe=tx_df, index="transaction_id", time_index="timestamp")★Each table needs a uniqueindex. Settime_indexfor temporal data — it's what makes cutoff times / leakage-safety work.add_dataframe(..., logical_types={"zip": "Categorical", "age": "Integer"})★Types drive which primitives apply. Woodwork logical types (Categorical, Integer, Double, Datetime, EmailAddress...) are inferred but overridable.add_dataframe(..., make_index=True) # create a synthetic indexUse when a table has no natural unique key.
es = es.add_relationship("customers", "customer_id", "transactions", "customer_id")★Order is (parent_df, parent_key, child_df, child_key) — one parent row, many child rows. The parent key must be that table's index.es.add_relationships([rel1, rel2, ...])Chain multiple relationships to model a full schema (customers → sessions → transactions).es · es.plot() · es["transactions"]★Print/plot the schema to sanity-check; index into a table's DataFrame.DFS follows relationshipskeyAggregation features only exist along declared relationships — no relationship, no cross-table features. Model the schema completely.