-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create built in way to visualize dataframe in Jupyter (#132)
- Loading branch information
Showing
4 changed files
with
199 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,43 @@ Releases happen quite often (weekly / every few days) at the moment, so updating | |
- Node version `>=18` | ||
- Rust version `>=1.59` - *Only needed for development* | ||
|
||
|
||
## Deno | ||
|
||
In Deno modules you can import polars straight from `npm`: | ||
|
||
```typescript | ||
import pl from "npm:nodejs-polars"; | ||
``` | ||
|
||
With Deno 1.37, you can use the `display` function to display a `DataFrame` in the notebook: | ||
|
||
```typescript | ||
import pl from "npm:nodejs-polars"; | ||
import { display } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
let response = await fetch( | ||
"https://cdn.jsdelivr.net/npm/world-atlas@1/world/110m.tsv", | ||
); | ||
let data = await response.text(); | ||
let df = pl.readCSV(data, { sep: "\t" }); | ||
await display(df) | ||
``` | ||
|
||
With Deno 1.38, you only have to make the dataframe be the last expression in the cell: | ||
|
||
```typescript | ||
import pl from "npm:nodejs-polars"; | ||
let response = await fetch( | ||
"https://cdn.jsdelivr.net/npm/world-atlas@1/world/110m.tsv", | ||
); | ||
let data = await response.text(); | ||
let df = pl.readCSV(data, { sep: "\t" }); | ||
df | ||
``` | ||
|
||
<img width="510" alt="image" src="https://github.com/pola-rs/nodejs-polars/assets/836375/90cf7bf4-7478-4919-b297-f8eb6a16196f"> | ||
|
||
___ | ||
|
||
## Documentation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const rawToEntityEntries = [ | ||
["&", "&"], | ||
["<", "<"], | ||
[">", ">"], | ||
['"', """], | ||
["'", "'"], | ||
] as const; | ||
|
||
const rawToEntity = new Map<string, string>(rawToEntityEntries); | ||
|
||
const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g"); | ||
|
||
/** | ||
* Escapes text for safe interpolation into HTML text content and quoted attributes | ||
*/ | ||
export function escapeHTML(str: string) { | ||
return str.replaceAll(rawRe, (m) => rawToEntity.get(m) ?? m); | ||
} |