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

# SampleRows

> Sample records by choosing a specific number or percentage of records

<Panel>
  <Info>
    Dependencies:

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

  <Info>
    Cluster requirements:

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

Use the SampleRows gem to sample records by choosing a specific number or percentage of records.

## Parameters

| Parameter         | Description                                                                         |
| ----------------- | ----------------------------------------------------------------------------------- |
| Sampling strategy | An option between sampling by number of records or percentage of records            |
| Sampling ratio    | The ratio of records that you wish to sample                                        |
| Random seed       | A number that lets you reproduce the random sample                                  |
| With replacement  | When enabled, this allows records to be returned to the sample pool after selection |

## Example code

<Tip>
  To see the compiled code of your project, [switch to the Code
  view](/data-engineering/development/pipelines/pipelines#project-editor) in the project header.
</Tip>

<CodeGroup>
  ```python example.py theme={null}
  def SampleRows_1(spark: SparkSession, in0: DataFrame) -> DataFrame:
   return in0.sample(withReplacement = False, fraction = 0.5)
  ```

  ```scala example.scala theme={null}
  object SampleRows_1 {
   def apply(context: Context, in: DataFrame): DataFrame =
   in.sample(false, "0.5".toDouble)
  }
  ```
</CodeGroup>
