---
title: limit
description: "DataFrame.limit method in PySpark: Limits the result count to the number specified."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframe/limit
---

# limit

Limits the result count to the number specified.

## Syntax

```
limit(num: int)
```

## Parameters

| Parameter | Type | Description                                                                                                                                |
| --------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `num`     | int  | Number of records to return. Will return this number of records or all records if the DataFrame contains less than this number of records. |

## Returns

`DataFrame`: Subset of the records.

## Examples

```python
df = spark.createDataFrame(
    [(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"])
df.limit(1).show()
# +---+----+
# |age|name|
# +---+----+
# | 14| Tom|
# +---+----+
df.limit(0).show()
# +---+----+
# |age|name|
# +---+----+
# +---+----+
```
