Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Scikit-Learn · Function

make_column_transformer

Creates a ColumnTransformer from transformer-and-column pairs without requiring explicit transformer names. Names are generated automatically from transformer types.

How it works

The function accepts transformer-and-column pairs, then constructs a ColumnTransformer that applies each estimator to its selected subset and combines the outputs. Transformer names are generated automatically from estimator types, while remainder controls what happens to unspecified columns.

Syntax

sklearn.compose.make_column_transformer(*transformers, remainder='drop', sparse_threshold=0.3, n_jobs=None, verbose=False, verbose_feature_names_out=True)

Parameters

NameTypeDescription
transformerstuplesTuples of (transformer, columns); transformer may be an estimator, 'drop', or 'passthrough', and columns identify the data subset.
remainder{'drop', 'passthrough'} or estimator, default='drop'Controls processing of columns not listed in transformers: 'drop', 'passthrough', or an estimator; default is 'drop'.
sparse_thresholdfloat, default=0.3Threshold used to decide whether the combined output is sparse; default is 0.3.
n_jobsint, default=NoneNumber of jobs used for fitting and transforming; default is None.
verbosebool, default=FalseWhether to print progress messages; default is False.
verbose_feature_names_outbool, default=TrueWhether generated feature names include transformer names; default is True.

Returns

A ColumnTransformer object.

Key points

  • Use the function to assemble column-specific preprocessing into a ColumnTransformer.
  • Unlike the constructor, it does not accept explicit transformer names.
  • Generated names are derived from each transformer’s type.
  • Pass one tuple per operation, pairing a transformer with the columns it should receive.
  • Column selection can be delegated to make_column_selector when names or dtypes determine the subsets.
  • Set remainder to passthrough to preserve columns not covered by explicit transformer tuples.
  • Retained remainder columns are concatenated with transformed outputs.

Common mistakes

  • Unlisted columns are discarded unless remainder is set to passthrough or to an estimator.
  • A remainder estimator must implement both fit and transform.

Example: Build a mixed-column preprocessor

from sklearn.compose import make_column_transformer
from sklearn.preprocessing import OneHotEncoder, StandardScaler

preprocessor = make_column_transformer(
    (StandardScaler(), ["age"]),
    (OneHotEncoder(handle_unknown="ignore"), ["city"]),
    remainder="drop",
)

Creates a transformer that scales the numeric column and one-hot encodes the categorical column; other columns are discarded.

When to use it

Heterogeneous tabular preprocessing

Apply numeric scaling and categorical encoding in one preprocessing object.

Pass through remaining features

Keep columns not covered by explicit transformations.

Dynamic column selection

Select feature groups based on names or data types.

Interview questions

QWhat does make_column_transformer simplify?

It is a convenience wrapper around the ColumnTransformer constructor. It creates transformer names automatically from the types of the supplied estimators, so callers provide transformer-and-column tuples without explicit names.

Follow-up: What happens to columns omitted from those tuples? By default they are dropped; remainder='passthrough' retains them, or an estimator processes them.

QWhat can each transformer tuple contain?

Each tuple has the form (transformer, columns). The transformer can be an estimator, 'drop', or 'passthrough', and an estimator must support fit and transform.

Follow-up: How can selections be generalized? Use selectors such as make_column_selector to choose columns by name pattern or data type.

QWhat object does the function return?

The function returns a ColumnTransformer object. That object applies the configured operations to the selected subsets and combines their results into one output.

Follow-up: How is output sparsity controlled? The returned ColumnTransformer exposes sparse_threshold, which determines whether a combined sparse result is returned.

  • ColumnTransformer
  • make_column_selector

Source: make_column_transformer — scikit-learn 1.9.1 documentation. Checked 2026-10-15.