> ## 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_rows

> Filter rows using graphext's advanced query syntax (similar to Elasticsearch). 

## 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">
      This simple query creates a new dataset only including those rows where the 'age' columns is greater than 18:

      ```stan theme={null}
      filter_rows(ds, {"query": "age: >18"}) -> (dsf)
      ```
    </Tab>

    <Tab title="Example 2">
      Filter clients who are legally adults.

      ```stan theme={null}
      filter_rows(ds, {"query": "age:>18"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 3">
      Select clients who are exactly 19 years old.

      ```stan theme={null}
      filter_rows(ds, {"query": "age:19"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 4">
      Filter clients who are over 27 years old but below the mean age.

      ```stan theme={null}
      filter_rows(ds, {"query": "age:>27 AND < MEAN"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 5">
      Select all clients belonging to the cool class.

      ```stan theme={null}
      filter_rows(ds, {"query": "class: cool"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 6">
      Select clients belonging to the 4 most frequent classes.

      ```stan theme={null}
      filter_rows(ds, {"query": "class: TOP(4)"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 7">
      Filter clients aged 18 who earn more than 50 dollars monthly on average.

      ```stan theme={null}
      filter_rows(ds, {"query": "(age: 18) AND ('avg monthly income':>50)"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 8">
      Filter fire dates in 2020.

      ```stan theme={null}
      filter_rows(ds, {"query": "'Fire Date': >=2020-01-01 AND <=2020-12-31"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 9">
      Select rows where the text column contains both "he" and "she".

      ```stan theme={null}
      filter_rows(ds, {"query": "text: he AND she"}) -> (ds_out)
      ```
    </Tab>

    <Tab title="Example 10">
      Filter rows where 'Average Monthly Hours' is greater than 5 and less than 7.

      ```stan theme={null}
      filter_rows(ds, {"query": "'Average Monthly Hours':>5 AND <7"}) -> (ds_out)
      ```
    </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_rows(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 dataset containing the same columns as the input dataset but without the filtered rows.
  </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="query" type="string" required>
    The *graphext advanced query* used to identify the rows to keep.
  </ParamField>
</Accordion>
