## StepDrop


Remove the selected columns.


Usage

``` python
StepDrop(
    columns,
    *,
    id=None,
)
```


Every column the selector matches is dropped, and no new columns are produced. Nothing is estimated: which columns to drop is decided by the selector alone, fixed against the training data frame's schema. To drop columns by a data-driven rule instead, see [StepDropCorr](StepDropCorr.md#mlfeatures.StepDropCorr), [StepDropZeroVariance](StepDropZeroVariance.md#mlfeatures.StepDropZeroVariance) or [StepDropNearZeroVariance](StepDropNearZeroVariance.md#mlfeatures.StepDropNearZeroVariance).

The selection is taken at face value, so a selector that reaches a column with a role other than `"feature"` drops that column too.

See [Arguments shared across steps](../user-guide/common-step-arguments.md) for the arguments this step shares with the others.


## Parameters


`columns: Selector`  
Columns to remove. Accepts a single column name, a list of names, a mlfeatures selector such as [Selectors.features()](Selectors.md#mlfeatures.Selectors.features) (see [Selectors](Selectors.md#mlfeatures.Selectors) for the full set), or a narwhals or polars selector (`narwhals.selectors.numeric()`, `polars.selectors.numeric()`). Selectors are resolved against the data frame's schema when the recipe is fitted, so the same selector works on any backend. Any dtype is accepted.

`id: str | None = None`  
Stable step identifier. Defaults to `"drop"`; a second step of this type in the same recipe becomes `"drop_2"`, and passing an `id` already used in the recipe is an error.


## Examples

It is often easier to say what to remove than to enumerate what to keep:


``` python
df = pd.DataFrame({"x": [1.0, 2.0, 3.0], "note": ["a", "b", "c"]})
df
```


|     | x   | note |
|-----|-----|------|
| 0   | 1.0 | a    |
| 1   | 2.0 | b    |
| 2   | 3.0 | c    |


Specifying the step touches no data:


``` python
recipe = Recipe().add(StepDrop(s.string_features()))
recipe
```


    Recipe (untrained)
      Inputs: no roles assigned
      Steps:
        step_drop(select(role='feature', type=String))  [untrained]


[fit()](Step.fit.md#mlfeatures.Step.fit) resolves the selector against the training schema:


``` python
fitted = recipe.fit(df)
fitted
```


    Recipe (trained)
      Inputs: 1 columns (1 feature)
      Steps:
        step_drop(note)  [trained]


[transform()](Step.transform.md#mlfeatures.Step.transform) drops the columns it matched:


``` python
fitted.transform(df)
```


|     | x   |
|-----|-----|
| 0   | 1.0 |
| 1   | 2.0 |
| 2   | 3.0 |
