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

# RowDistributor

> Create multiple DataFrames based on filter conditions

<Panel>
  <Info>
    Dependencies:

    * ProphecySparkBasicsPython 0.0.1+
    * ProphecySparkBasicsScala 0.0.1+
  </Info>

  <Info>
    Cluster requirements:

    * UC dedicated clusters 14.3+ supported
    * UC standard clusters 14.3+ supported
    * Livy clusters 3.0.1+ supported
  </Info>
</Panel>

Use the RowDistributor gem to create multiple DataFrames based on provided filter conditions from an input DataFrame.

This is useful for cases where rows from the input DataFrame needs to be distributed into multiple DataFrames in different ways for downstream gems.

## Parameters

| Parameter         | Description                                                                                               | Required |
| ----------------- | --------------------------------------------------------------------------------------------------------- | -------- |
| DataFrame         | Input DataFrame for which rows needs to be distributed into multiple DataFrames                           | True     |
| Filter Conditions | Boolean Type column or boolean expression for each output tab. Supports SQL, Python and Scala expressions | True     |

## Example

<img src="https://mintcdn.com/prophecy-62973bd0/J5UDJ9ATlxoXhTI3/data-engineering/gems/join-split/img/rowdistributor_eg_1.png?fit=max&auto=format&n=J5UDJ9ATlxoXhTI3&q=85&s=e8d2f0146011c6751177e181fce44ae9" alt="Row distributor 1" width="1748" height="850" data-path="data-engineering/gems/join-split/img/rowdistributor_eg_1.png" />

<Info>
  Number of outputs can be changed as needed by clicking the `+` button.
</Info>

## Generated Code

<CodeGroup>
  ```python example.py theme={null}
  def RowDistributor(spark: SparkSession, in0: DataFrame) -> (DataFrame, DataFrame, DataFrame):
   df1 = in0.filter((col("order_status") == lit("Started")))
   df2 = in0.filter((col("order_status") == lit("Approved")))
   df3 = in0.filter((col("order_status") == lit("Finished")))

   return df1, df2, df3
  ```

  ```scala example.scala theme={null}
  object RowDistributor {

   def apply(
   spark: SparkSession,
   in: DataFrame
   ): (DataFrame, DataFrame, DataFrame) =
   (in.filter(col("order_status") === lit("Started")),
   in.filter(col("order_status") === lit("Approved")),
   in.filter(col("order_status") === lit("Finished"))
   )

  }
  ```
</CodeGroup>
