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

# segment_rows

> Create a segmentation 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 segmentation differentiating between adults and minors:

      ```stan theme={null}
      segment_rows(ds, {"adult": "age: >=18", "minor": "age: <18"}) -> (ds.segmentation)
      ```
    </Tab>

    <Tab title="Example 2">
      Flag clients that are exactly 19 years old and 21 years old

      ```stan theme={null}
      segment_rows(ds, {"nineteen": "age:19", "twentyone": "age:21"}) -> (ds.segmentation)
      ```
    </Tab>

    <Tab title="Example 3">
      Bin competitors who are over 27 years of age but below the mean age

      ```stan theme={null}
      segment_rows(ds, {"over_twentyseven_below_mean": "age:>27 AND < MEAN"}) -> (ds.segmentation)
      ```
    </Tab>

    <Tab title="Example 4">
      Select all who belong to the cool class

      ```stan theme={null}
      segment_rows(ds, {"cool_clients": "class: cool"}) -> (ds.segmentation)
      ```
    </Tab>

    <Tab title="Example 5">
      Segment all belonging to the most frequent 4 classes and least frequent 3

      ```stan theme={null}
      segment_rows(ds, {"most_freq": "class: TOP(4)", "least_freq": "class: BOTTOM(3)"}) -> (ds.segmentation)
      ```
    </Tab>

    <Tab title="Example 6">
      For those aged 18, separate on who earn more than 5 dollars monthly on average and 5 or less

      ```stan theme={null}
      segment_rows(ds, {"high_inc": "(age: 18) AND ('avg monthly income':>5)", "low_inc": "(age: 18) AND ('avg monthly income':<=5)"}) -> (ds.segmentation)
      ```
    </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}
      segment_rows(ds_in: dataset, {
          "param": value,
          ...
      }) -> (segmentation: column)
      ```
    </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 use for creating a segmentation.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="segmentation" type="column" required />
</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="Items" type="string">
    The *graphext advanced query* used to identify the rows to include in each segment.

    <Accordion title="Options" />
  </ParamField>
</Accordion>
