polars.DataFrame.item
-
Return the DataFrame as a scalar, or return the element at the given row/column.
- Parameters:
-
- row
-
Optional row index.
- column
-
Optional column index or name.
See also
-
row -
Get the values of a single row, either by index or by predicate.
Notes
If row/col not provided, this is equivalent to
df[0,0], with a check that the shape is (1,1). With row/col, this is equivalent todf[row,col].Examples
>>> df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) >>> df.select((pl.col("a") * pl.col("b")).sum()).item() 32 >>> df.item(1, 1) 5 >>> df.item(2, "b") 6
DataFrame.item(
row: int | None = None,
column: int | str | None = None,
) → Any
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.item.html