Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
KDruzhkin committed Jun 3, 2024
1 parent b411e08 commit 8db6e82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# --8<-- [end:setup]


# --8<-- [start:hypothenuse]
def hypothenuse(df: pl.DataFrame, col_x: str, col_y: str, col_r: str) -> pl.DataFrame:
# --8<-- [start:hypotenuse]
def hypotenuse(df: pl.DataFrame, col_x: str, col_y: str, col_r: str) -> pl.DataFrame:
"Apply the Pythagorean theorem."
x_squared = pl.col(col_x).pow(2)
y_squared = pl.col(col_y).pow(2)
r_squared = x_squared + y_squared
r = r_squared.sqrt()
return df.with_columns(r.alias(col_r))
# --8<-- [end:hypothenuse]
# --8<-- [end:hypotenuse]


# --8<-- [start:pipe]
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/pipes/building_abstractions_with_pipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

All programming languages (e.g. Rust or Python) provide some _primitive operations_ (e.g. `+` or `sqrt`), some means of _combining_ them into complex pipelines, and some means of _hiding complexity behind abstractions_. An abstraction (e.g. a named function) is a simple name for a piece of complex code.

The API of Polars is a small domain-specific language. This language cannot (and should not) accomodate all needs with an ever-growing vocabulary of primitive operations. Instead it gives you the tools to build your own abstractions.
The API of Polars is a small domain-specific language. This language cannot (and should not) accommodate all needs with an ever-growing vocabulary of primitive operations. Instead it gives you the tools to build your own abstractions.

```python exec="on" session="user-guide/pipes/building_abstractions_with_pipes"
--8<-- "python/user-guide/pipes/building_abstractions_with_pipes.py:setup"
```

Suppose, for example, that you frequently have to apply the Pythagorean theorem to your data. Create a function for that:

{{code_block('user-guide/pipes/building_abstractions_with_pipes','hypothenuse',[])}}
{{code_block('user-guide/pipes/building_abstractions_with_pipes','hypotenuse',[])}}

```python exec="on" session="user-guide/pipes/building_abstractions_with_pipes"
--8<-- "python/user-guide/pipes/building_abstractions_with_pipes.py:hypothenuse"
--8<-- "python/user-guide/pipes/building_abstractions_with_pipes.py:hypotenuse"
```

... and apply it with `pipe`:
Expand Down

0 comments on commit 8db6e82

Please sign in to comment.