CategoryBinarizer class

Definition

A transformer produces binary columns from a TimeSeriesDataFrame.

Also known as "One-Hot Encoding" or "Dummy Coding."

CategoryBinarizer(prefix=None, prefix_sep='_', dummy_na=False, columns=None, encode_all_categoricals=False, drop_first=False)
Inheritance

Methods

fit(X, y=None)

Fit the binarizer on the input data.

transform(X, y=None)

Transform requested columns via the encoder.

fit(X, y=None)

Fit the binarizer on the input data.

fit(X, y=None)

Parameters

X
DataFrame

Input data

y

Ignored. Necessary for pipeline compatibility

Returns

Fitted transform

Return type

CategoryBinarizer

transform(X, y=None)

Transform requested columns via the encoder.

transform(X, y=None)

Parameters

X
DataFrame

Input data

y

Ignored. Necessary for pipeline compatibility

Returns

Data with dummy coded categoricals

Return type

Attributes

columns

Names of columns to consider as categorical.

If columns=None then all the columns with object or category dtype will be encoded.

columns_in_fit

Read-only property containing list of encoded columns from last fit.

There are situations where columns_in_fit and columns are different. For instance, if columns=None when fit is called, fit will save a list of all columns with dtyp=object or dtype=category in the columns_in_fit property. These columns will then be encoded by transform.