s.exceptions.DuplicateError.html)
    * [ polars.exceptions.InvalidOperationError ](../../api/polars.exceptions.InvalidOperationError.html)
    * [ polars.exceptions.NoDataError ](../../api/polars.exceptions.NoDataError.html)
    * [ polars.exceptions.NoRowsReturnedError ](../../api/polars.exceptions.NoRowsReturnedError.html)
    * [ polars.exceptions.PolarsError ](../../api/polars.exceptions.PolarsError.html)
    * [ polars.exceptions.PolarsPanicError ](../../api/polars.exceptions.PolarsPanicError.html)
    * [ polars.exceptions.RowsError ](../../api/polars.exceptions.RowsError.html)
    * [ polars.exceptions.SchemaError ](../../api/polars.exceptions.SchemaError.html)
    * [ polars.exceptions.SchemaFieldNotFoundError ](../../api/polars.exceptions.SchemaFieldNotFoundError.html)
    * [ polars.exceptions.ShapeError ](../../api/polars.exceptions.ShapeError.html)
    * [ polars.exceptions.StructFieldNotFoundError ](../../api/polars.exceptions.StructFieldNotFoundError.html)
    * [ polars.exceptions.TooManyRowsReturnedError ](../../api/polars.exceptions.TooManyRowsReturnedError.html)

  * [ Testing ](../../testing.html) __
    * [ polars.testing.assert_frame_equal ](../../api/polars.testing.assert_frame_equal.html)
    * [ polars.testing.assert_frame_not_equal ](../../api/polars.testing.assert_frame_not_equal.html)
    * [ polars.testing.assert_series_equal ](../../api/polars.testing.assert_series_equal.html)
    * [ polars.testing.assert_series_not_equal ](../../api/polars.testing.assert_series_not_equal.html)
    * [ polars.testing.parametric.dataframes ](../../api/polars.testing.parametric.dataframes.html)
    * [ polars.testing.parametric.series ](../../api/polars.testing.parametric.series.html)
    * [ polars.testing.parametric.column ](../../api/polars.testing.parametric.column.html)
    * [ polars.testing.parametric.columns ](../../api/polars.testing.parametric.columns.html)
    * [ polars.testing.parametric.create_list_strategy ](../../api/polars.testing.parametric.create_list_strategy.html)
    * [ polars.testing.parametric.load_profile ](../../api/polars.testing.parametric.load_profile.html)
    * [ polars.testing.parametric.set_profile ](../../api/polars.testing.parametric.set_profile.html)

  * [ Metadata ](../../metadata.html) __
    * [ polars.build_info ](../../api/polars.build_info.html)
    * [ polars.get_index_type ](../../api/polars.get_index_type.html)
    * [ polars.show_versions ](../../api/polars.show_versions.html)
    * [ polars.thread_pool_size ](../../api/polars.thread_pool_size.html)
    * [ polars.threadpool_size ](../../api/polars.threadpool_size.html)

  * [ __ ](../../../index.html)
  * [ Python API reference ](../../index.html)
  * __
  * [ Manipulation/selection ](../modify_select.html)
  * polars.LazyF... 

#  polars.LazyFrame.with_row_index  #

LazyFrame.  with_row_index  (  _ name  :  [ str
](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.12\)") =
'index'  _ , _ offset  :  [ int
](https://docs.python.org/3/library/functions.html#int "\(in Python v3.12\)")
=  0  _ )  →  Self  [ [source]  ](https://github.com/pola-
rs/polars/blob/main/py-polars/polars/lazyframe/frame.py#L4734-L4809) #

    

Add a row index as the first column in the LazyFrame.

Parameters  :

    

**name**

    

Name of the index column.

**offset**

    

Start the index at this offset. Cannot be negative.

Warning

Using this function can have a negative effect on query performance. This may,
for instance, block predicate pushdown optimization.

Notes

The resulting column does not have any special properties. It is a regular
column of type ` UInt32  ` (or ` UInt64  ` in ` polars-u64-idx  ` ).

Examples

    
    
    >>> lf = pl.LazyFrame(
    ...     {
    ...         "a": [1, 3, 5],
    ...         "b": [2, 4, 6],
    ...     }
    ... )
    >>> lf.with_row_index().collect()
    shape: (3, 3)
    ┌───────┬─────┬─────┐
    │ index ┆ a   ┆ b   │
    │ ---   ┆ --- ┆ --- │
    │ u32   ┆ i64 ┆ i64 │
    ╞