|
a |
|
b/docs/data/polars.md |
|
|
1 |
# Polars |
|
|
2 |
|
|
|
3 |
??? abstract "TLDR" |
|
|
4 |
|
|
|
5 |
```{ .python .no-check } |
|
|
6 |
import edsnlp |
|
|
7 |
|
|
|
8 |
stream = edsnlp.data.from_polars(df, converter="omop") |
|
|
9 |
stream = stream.map_pipeline(nlp) |
|
|
10 |
res = stream.to_polars(converter="omop") |
|
|
11 |
# or equivalently |
|
|
12 |
edsnlp.data.to_polars(stream, converter="omop") |
|
|
13 |
``` |
|
|
14 |
|
|
|
15 |
We provide methods to read and write documents (raw or annotated) from and to Polars DataFrames. |
|
|
16 |
|
|
|
17 |
As an example, imagine that we have the following OMOP dataframe (we'll name it `note_df`) |
|
|
18 |
|
|
|
19 |
| note_id | note_text | note_datetime | |
|
|
20 |
|--------:|:----------------------------------------------|:--------------| |
|
|
21 |
| 0 | Le patient est admis pour une pneumopathie... | 2021-10-23 | |
|
|
22 |
|
|
|
23 |
## Reading from a Polars Dataframe {: #edsnlp.data.polars.from_polars } |
|
|
24 |
|
|
|
25 |
::: edsnlp.data.polars.from_polars |
|
|
26 |
options: |
|
|
27 |
heading_level: 3 |
|
|
28 |
show_source: false |
|
|
29 |
show_toc: false |
|
|
30 |
show_bases: false |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
## Writing to a Polars DataFrame {: #edsnlp.data.polars.to_polars } |
|
|
34 |
|
|
|
35 |
::: edsnlp.data.polars.to_polars |
|
|
36 |
options: |
|
|
37 |
heading_level: 3 |
|
|
38 |
show_source: false |
|
|
39 |
show_toc: false |
|
|
40 |
show_bases: false |