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

# Limit gem for Data Engineering

> Limit the number of rows

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

Limits the number of rows in the output.

## Parameters

| Parameter | Description                                                               |
| :-------- | :------------------------------------------------------------------------ |
| DataFrame | Input DataFrame                                                           |
| Limit     | Number of rows required in output. Allowed range: \[0, 2<sup>31</sup> -1] |

## Limit to 10 rows

If you want to limit your output to 10 rows, you can input `10` in the Limit gem.

<img src="https://mintcdn.com/prophecy-62973bd0/5tvw_2e98LqB5rz7/data-engineering/gems/transform/img/limit_eg_1.png?fit=max&auto=format&n=5tvw_2e98LqB5rz7&q=85&s=e801eba5961ef1dd24bc081050852845" alt="Example usage of Limit" width="940" height="268" data-path="data-engineering/gems/transform/img/limit_eg_1.png" />

<Note>
  [Data samples](/data-engineering/development/runs/execution) generated before the Limit gem might also be limited. This is because Spark tries to push the limit down to earlier stages of execution to minimize data processing. This means Spark may reduce the number of rows fetched from the source or processed in earlier transformations.
</Note>

## Code

<CodeGroup>
  ```python example.py theme={null}
  def limit(spark: SparkSession, in0: DataFrame) -> DataFrame:
   return in0.limit(10)
  ```

  ```scala example.scala theme={null}
  object limit {
   def apply(spark: SparkSession, in: DataFrame): DataFrame =
   in.limit(10)
  }
  ```
</CodeGroup>
