From 8107c732072c69517d0bdedab643a1bf442e665d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:14:52 +0100 Subject: [PATCH] docs: Fix example of lazy schema verification Fixes #19058. --- docs/source/src/python/user-guide/lazy/schema.py | 6 ++---- docs/source/user-guide/lazy/schemas.md | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/source/src/python/user-guide/lazy/schema.py b/docs/source/src/python/user-guide/lazy/schema.py index 1b8971b84597..b77469434f51 100644 --- a/docs/source/src/python/user-guide/lazy/schema.py +++ b/docs/source/src/python/user-guide/lazy/schema.py @@ -10,16 +10,14 @@ # --8<-- [end:schema] # --8<-- [start:lazyround] -lf = pl.LazyFrame({"foo": ["a", "b", "c"], "bar": [0, 1, 2]}).with_columns( - pl.col("bar").round(0) -) +lf = pl.LazyFrame({"foo": ["a", "b", "c"]}).with_columns(pl.col("foo").round(2)) # --8<-- [end:lazyround] # --8<-- [start:typecheck] try: print(lf.collect()) except Exception as e: - print(e) + print(f"{type(e).__name__}: {e}") # --8<-- [end:typecheck] # --8<-- [start:lazyeager] diff --git a/docs/source/user-guide/lazy/schemas.md b/docs/source/user-guide/lazy/schemas.md index c6d2ede22059..d63f1af115ad 100644 --- a/docs/source/user-guide/lazy/schemas.md +++ b/docs/source/user-guide/lazy/schemas.md @@ -15,11 +15,11 @@ The schema plays an important role in the lazy API. One advantage of the lazy API is that Polars will check the schema before any data is processed. This check happens when you execute your lazy query. -We see how this works in the following simple example where we call the `.round` expression on the integer `bar` column. +We see how this works in the following simple example where we call the `.round` expression on the string column `foo`. {{code_block('user-guide/lazy/schema','lazyround',['with_columns'])}} -The `.round` expression is only valid for columns with a floating point dtype. Calling `.round` on an integer column means the operation will raise an `InvalidOperationError` when we evaluate the query with `collect`. This schema check happens before the data is processed when we call `collect`. +The `.round` expression is only valid for columns with a numeric data type. Calling `.round` on a string column means the operation will raise an `InvalidOperationError` when we evaluate the query with `collect`. This schema check happens before the data is processed when we call `collect`. {{code_block('user-guide/lazy/schema','typecheck',[])}}