> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# filter_range

> Filter rows based on the numeric values in a given column. 

Keeps or drops rows where numeric values fall within a desired range, i.e. are greater than a certain minimum,
and/or smaller than a maximum value.

## Usage

The following examples show how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      The following example creates a new dataset including only those rows whose satisfaction\_level is between 0.6 and 0.9 (inclusive).

      ```stan theme={null}
      filter_range(ds, {"column": "satisfaction_level", "min": 0.6, "max": 0.9}) -> (ds_filtered)
      ```
    </Tab>

    <Tab title="Example 2">
      Using the exclude parameter, the next example creates a dataset including only those rows whose satisfaction\_level falls outside the range 0.6–0.9.

      ```stan theme={null}
      filter_range(ds, {"column": "satisfaction_level", "min": 0.6, "max": 0.9, "exclude": true}) -> (ds_filtered)
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      filter_range(ds_in: dataset, {
          "param": value,
          ...
      }) -> (ds_out: dataset)
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="ds_in" type="dataset" required>
    An input dataset to filter.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="ds_out" type="dataset" required>
    A new dataset containing the same columns as the input dataset but only those rows passing the filter condition.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="column" type="string (ds_in.column:number)" required>
    Name of the column to apply the filter to.
  </ParamField>

  <ParamField path="exclude" type="boolean" default="false">
    If `true`, values within the specified range will be *excluded* from the resulting dataset.
  </ParamField>

  <ParamField path="max" type="number">
    Maximum value in the selected column to pass the filter (to be included).
    Either this or the `min` parameter must be specified.
  </ParamField>

  <ParamField path="min" type="number">
    Minimum value in the selected column to pass the filter (to be included).
    Either this or the `max` parameter must be specified.
  </ParamField>
</Accordion>
