Skip to content

Commit

Permalink
docs: tweak polars example in intro
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Aug 26, 2024
1 parent e5b3d79 commit 3d65e0b
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions docs/get-started/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,26 @@ gt_tbl

That doesn't look too bad! Sure, it's basic but we really didn't really ask for much. We did receive a proper table with column labels and the data. Oftentimes however, you'll want a bit more: a **Table header**, a **Stub**, and sometimes *source notes* in the **Table Footer** component.

## **Polars** DataFrame is supported
`GT` not only accepts **Pandas** DataFrames but also **Polars** DataFrames. You can pass a **Polars** DataFrame to `GT` like this:
## **Polars** DataFrame support

`GT` accepts both **Pandas** and **Polars** DataFrames. You can pass a **Polars** DataFrame to `GT`, or use its `DataFrame.style` property.

```{python}
import polars as pl
df_polars = pl.from_pandas(islands_mini)
# pl.from_pandas(islands_mini) is a Polars DataFrame
gt_tbl = GT(pl.from_pandas(islands_mini))
# Approach 1: call GT ----
GT(df_polars)
# Show the output table
gt_tbl
# Approach 2: Polars style property ----
df_polars.style
```

During the development of **Great Tables**, we received a lot of support from the developers of **Polars**. After **Polars v1**, you can also get a `GT` object using `DataFrame.style`, like this:

```{python}
# pl.from_pandas(islands_mini).style returns a `GT` object
gt_tbl = pl.from_pandas(islands_mini).style
# Show the output table
gt_tbl
```
:::{.callout-note}
The `polars.DataFrame.style` property is currently considered [unstable](https://docs.pola.rs/api/python/stable/reference/dataframe/style.html#polars.DataFrame.style), and may change in the future. Using `GT` on a **Polars** DataFrame will always work.
:::

Please note that this feature is considered [unstable](https://docs.pola.rs/api/python/stable/reference/dataframe/style.html#polars.DataFrame.style) and should be used with caution.

## Some Beautiful Examples

Expand Down

0 comments on commit 3d65e0b

Please sign in to comment.