Spaces:
Running
Running
keeping only code cell for examples - polars
Browse filesCo-authored-by: Akshay Agrawal <[email protected]>
- polars/01_why_polars.py +0 -19
polars/01_why_polars.py
CHANGED
@@ -91,25 +91,6 @@ def _(mo):
|
|
91 |
mo.md(
|
92 |
r"""
|
93 |
The same example can be worked out in Polars like below,
|
94 |
-
|
95 |
-
```python
|
96 |
-
import polars as pl
|
97 |
-
|
98 |
-
df_pl = pl.DataFrame(
|
99 |
-
{
|
100 |
-
"Gender": ["Male", "Female", "Male", "Female", "Male", "Female",
|
101 |
-
"Male", "Female", "Male", "Female"],
|
102 |
-
"Age": [13, 15, 17, 19, 21, 23, 25, 27, 29, 31],
|
103 |
-
"Height_CM": [150.0, 170.0, 146.5, 142.0, 155.0, 165.0, 170.8, 130.0, 132.5, 162.0]
|
104 |
-
}
|
105 |
-
)
|
106 |
-
|
107 |
-
# query: average height of male and female after the age of 15 years
|
108 |
-
|
109 |
-
# filter, groupby and aggregation using method chaining
|
110 |
-
result_pl = df_pl.filter(pl.col("Age") > 15).group_by("Gender").agg(pl.mean("Height_CM"))
|
111 |
-
result_pl
|
112 |
-
```
|
113 |
"""
|
114 |
)
|
115 |
return
|
|
|
91 |
mo.md(
|
92 |
r"""
|
93 |
The same example can be worked out in Polars like below,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
"""
|
95 |
)
|
96 |
return
|