Spaces:
Running
Running
Raine Hoang
Srihari Thyagarajan
commited on
Apply suggestions from code review
Browse filesCo-authored-by: Srihari Thyagarajan <[email protected]>
- polars/02_dataframes.py +9 -8
polars/02_dataframes.py
CHANGED
@@ -32,7 +32,8 @@ def _(mo):
|
|
32 |
|
33 |
In this tutorial, we will go over the central data structure for structured data, DataFrames. There are a multitude of packages that work with DataFrames, but we will be focusing on the way Polars uses them the different options it provides.
|
34 |
|
35 |
-
|
|
|
36 |
"""
|
37 |
)
|
38 |
return
|
@@ -60,7 +61,7 @@ def _(mo):
|
|
60 |
def _(mo):
|
61 |
mo.md(
|
62 |
r"""
|
63 |
-
There are 5 data types that can be converted into a DataFrame.
|
64 |
|
65 |
1. Dictionary
|
66 |
2. Sequence
|
@@ -78,7 +79,7 @@ def _(mo):
|
|
78 |
r"""
|
79 |
#### Dictionary
|
80 |
|
81 |
-
Dictionaries are structures that store data as key:value pairs. Let's say we have the following dictionary:
|
82 |
"""
|
83 |
)
|
84 |
return
|
@@ -93,7 +94,7 @@ def _():
|
|
93 |
|
94 |
@app.cell(hide_code=True)
|
95 |
def _(mo):
|
96 |
-
mo.md(r"""In order to convert this dictionary into a DataFrame, we simply need to pass it into the data parameter in the
|
97 |
return
|
98 |
|
99 |
|
@@ -144,7 +145,7 @@ def _(pl, seq_data):
|
|
144 |
|
145 |
@app.cell(hide_code=True)
|
146 |
def _(mo):
|
147 |
-
mo.md(r"""Notice that since we didn't specify the column names, Polars automatically named them
|
148 |
return
|
149 |
|
150 |
|
@@ -242,7 +243,7 @@ def _(mo):
|
|
242 |
return
|
243 |
|
244 |
|
245 |
-
@app.cell
|
246 |
def _(mo):
|
247 |
mo.md(
|
248 |
r"""
|
@@ -387,7 +388,7 @@ def _(mo):
|
|
387 |
return
|
388 |
|
389 |
|
390 |
-
@app.cell
|
391 |
def _(mo):
|
392 |
mo.md(
|
393 |
r"""
|
@@ -413,7 +414,7 @@ def _(pl):
|
|
413 |
return
|
414 |
|
415 |
|
416 |
-
@app.cell
|
417 |
def _(mo):
|
418 |
mo.md(r"""Now let's try setting strict to `False`.""")
|
419 |
return
|
|
|
32 |
|
33 |
In this tutorial, we will go over the central data structure for structured data, DataFrames. There are a multitude of packages that work with DataFrames, but we will be focusing on the way Polars uses them the different options it provides.
|
34 |
|
35 |
+
/// Note
|
36 |
+
The following tutorial has been adapted from the Polars [documentation](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html).
|
37 |
"""
|
38 |
)
|
39 |
return
|
|
|
61 |
def _(mo):
|
62 |
mo.md(
|
63 |
r"""
|
64 |
+
There are [5 data types](https://github.com/pola-rs/polars/blob/py-1.29.0/py-polars/polars/dataframe/frame.py#L197) that can be converted into a DataFrame.
|
65 |
|
66 |
1. Dictionary
|
67 |
2. Sequence
|
|
|
79 |
r"""
|
80 |
#### Dictionary
|
81 |
|
82 |
+
Dictionaries are structures that store data as `key:value` pairs. Let's say we have the following dictionary:
|
83 |
"""
|
84 |
)
|
85 |
return
|
|
|
94 |
|
95 |
@app.cell(hide_code=True)
|
96 |
def _(mo):
|
97 |
+
mo.md(r"""In order to convert this dictionary into a DataFrame, we simply need to pass it into the data parameter in the `.DataFrame()` method like so.""")
|
98 |
return
|
99 |
|
100 |
|
|
|
145 |
|
146 |
@app.cell(hide_code=True)
|
147 |
def _(mo):
|
148 |
+
mo.md(r"""Notice that since we didn't specify the column names, Polars automatically named them `column_0`, `column_1`, and `column_2`. Later, we will show you how to specify the names of the columns.""")
|
149 |
return
|
150 |
|
151 |
|
|
|
243 |
return
|
244 |
|
245 |
|
246 |
+
@app.cell(hide_code=True)
|
247 |
def _(mo):
|
248 |
mo.md(
|
249 |
r"""
|
|
|
388 |
return
|
389 |
|
390 |
|
391 |
+
@app.cell(hide_code=True)
|
392 |
def _(mo):
|
393 |
mo.md(
|
394 |
r"""
|
|
|
414 |
return
|
415 |
|
416 |
|
417 |
+
@app.cell(hide_code=True)
|
418 |
def _(mo):
|
419 |
mo.md(r"""Now let's try setting strict to `False`.""")
|
420 |
return
|