df = pd.DataFrame({"x": [1.0, 2.0, 3.0]})
df| x | |
|---|---|
| 0 | 1.0 |
| 1 | 2.0 |
| 2 | 3.0 |
Add a constant column with a fixed value.
Usage
A single constant column is added, by default a column of ones named "intercept".
See Arguments shared across steps for the arguments this step shares with the others.
value: float = 1.0The constant to fill the new column with. Default 1.0. The column’s dtype follows the literal, so an int gives an integer column.
name: str = "intercept"Name of the new column. Default "intercept". A Recipe rejects the step if the data frame already has a column of this name.
role: str | None = "feature"Role assigned to the new column (see Roles). Default "feature".
id: str | None = None"intercept"; a second step of this type in the same recipe becomes "intercept_2", and passing an id already used in the recipe is an error.
A constant intercept column of ones is added; the input columns pass through untouched:
Specifying the step touches no data:
Recipe (untrained)
Inputs: no roles assigned
Steps:
step_intercept() [untrained]
fit() has nothing to estimate; the step is constant:
Recipe (trained)
Inputs: 1 columns (1 feature)
Steps:
step_intercept(intercept) [trained]
transform() adds the column:
value and name control what is added: