You are viewing documentation about an older version (1.12.1). View latest version

snowflake.snowpark.DataFrame.limit

DataFrame.limit(n: int, offset: int = 0) DataFrame[source]

Returns a new DataFrame that contains at most n rows from the current DataFrame, skipping offset rows from the beginning (similar to LIMIT and OFFSET in SQL).

Note that this is a transformation method and not an action method.

Parameters:
  • n – Number of rows to return.

  • offset – Number of rows to skip before the start of the result set. The default value is 0.

Example:

>>> df = session.create_dataframe([[1, 2], [3, 4]], schema=["a", "b"])
>>> df.limit(1).show()
-------------
|"A"  |"B"  |
-------------
|1    |2    |
-------------

>>> df.limit(1, offset=1).show()
-------------
|"A"  |"B"  |
-------------
|3    |4    |
-------------
Copy