From 7c1267702ea2d14a3096ff9a82b99dc4a7bbbdb8 Mon Sep 17 00:00:00 2001 From: romanovacca Date: Sat, 7 Oct 2023 20:23:00 +0200 Subject: [PATCH] fixed typo, small layout improvement, removed capitalization from variable name --- docs/src/python/user-guide/expressions/structs.py | 8 ++++---- docs/user-guide/expressions/structs.md | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/src/python/user-guide/expressions/structs.py b/docs/src/python/user-guide/expressions/structs.py index f209420a37ab..ee034a362bc6 100644 --- a/docs/src/python/user-guide/expressions/structs.py +++ b/docs/src/python/user-guide/expressions/structs.py @@ -26,24 +26,24 @@ # --8<-- [end:struct_unnest] # --8<-- [start:series_struct] -rating_Series = pl.Series( +rating_series = pl.Series( "ratings", [ {"Movie": "Cars", "Theatre": "NE", "Avg_Rating": 4.5}, {"Movie": "Toy Story", "Theatre": "ME", "Avg_Rating": 4.9}, ], ) -print(rating_Series) +print(rating_series) # --8<-- [end:series_struct] # --8<-- [start:series_struct_extract] -out = rating_Series.struct.field("Movie") +out = rating_series.struct.field("Movie") print(out) # --8<-- [end:series_struct_extract] # --8<-- [start:series_struct_rename] out = ( - rating_Series.to_frame() + rating_series.to_frame() .select(pl.col("ratings").struct.rename_fields(["Film", "State", "Value"])) .unnest("ratings") ) diff --git a/docs/user-guide/expressions/structs.md b/docs/user-guide/expressions/structs.md index ee0012fe4db4..61978bbc25e7 100644 --- a/docs/user-guide/expressions/structs.md +++ b/docs/user-guide/expressions/structs.md @@ -45,7 +45,7 @@ Polars will interpret a `dict` sent to the `Series` constructor as a `Struct`: !!! note "Constructing `Series` objects" - Note that `Series` here was constructed with the `name` of the series in the begninng, followed by the `values`. Providing the latter first + Note that `Series` here was constructed with the `name` of the series in the beginning, followed by the `values`. Providing the latter first is considered an anti-pattern in Polars, and must be avoided. ### Extracting individual values of a `Struct` @@ -60,7 +60,7 @@ Let's say that we needed to obtain just the `movie` value in the `Series` that w ### Renaming individual keys of a `Struct` -What if we need to rename individual `field`s of a `Struct` column? We first convert the `rating_Series` object to a `DataFrame` so that we can view the changes easily, and then use the `rename_fields` method: +What if we need to rename individual `field`s of a `Struct` column? We first convert the `rating_series` object to a `DataFrame` so that we can view the changes easily, and then use the `rename_fields` method: {{code_block('user-guide/expressions/structs','series_struct_rename',['struct.rename_fields'])}} @@ -84,7 +84,7 @@ We can identify the unique cases at this level also with `is_unique`! ### Multi-column ranking -Suppose, given that we know there are duplicates, we want to choose which rank gets a higher priority. We define _Count_ of ratings to be more important than the actual `Avg_Rating` themselves, and only use it to break a tie. We can then do: +Suppose, given that we know there are duplicates, we want to choose which rank gets a higher priority. We define `Count` of ratings to be more important than the actual `Avg_Rating` themselves, and only use it to break a tie. We can then do: {{code_block('user-guide/expressions/structs','struct_ranking',['is_duplicated', 'struct'])}}