Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<img src="https://posit-dev.github.io/gt-extras/assets/2011-nfl-season.png" width="600px">
</div>

> ⚠️ **gt-extras is currently in development, expect breaking changes.**


### What is [gt-extras](https://posit-dev.github.io/gt-extras)?

A collection of additional helper functions for creating beautiful tables with the [great-tables](https://posit-dev.github.io/great-tables/) package in Python.
Expand Down
4 changes: 0 additions & 4 deletions docs/articles/intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ For a more comprehensive guide, head over to the [Get Started](../get-started/)
- Use pre-built themes for quick styling
- Utilize helper utilities for common table tasks

::: {.callout-warning collapse="false"}
gt-extras is currently in development, expect breaking changes.
:::

## Contributing
If you encounter a bug, have usage questions, or want to share ideas to make this package better, please feel free to file an [issue](https://github.com/posit-dev/gt-extras/issues).

Expand Down
9 changes: 9 additions & 0 deletions gt_extras/tests/__snapshots__/test_colors.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,24 @@
# name: test_gt_data_color_by_group_multiple_groups_snap[pd_and_pl]
'''
<tbody class="gt_table_body">
<tr class="gt_group_heading_row">
<th class="gt_group_heading" colspan="1">1</th>
</tr>
<tr>
<td style="color: #FFFFFF; background-color: #000000;" class="gt_row gt_right">1</td>
</tr>
<tr class="gt_group_heading_row">
<th class="gt_group_heading" colspan="1">2</th>
</tr>
<tr>
<td style="color: #FFFFFF; background-color: #000000;" class="gt_row gt_right">2</td>
</tr>
<tr>
<td style="color: #000000; background-color: #9e9e9e;" class="gt_row gt_right">3</td>
</tr>
<tr class="gt_group_heading_row">
<th class="gt_group_heading" colspan="1">3</th>
</tr>
<tr>
<td style="color: #FFFFFF; background-color: #000000;" class="gt_row gt_right">4</td>
</tr>
Expand Down
15 changes: 12 additions & 3 deletions gt_extras/tests/__snapshots__/test_formatting.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@
#mycombinedtable .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
#mycombinedtable .gt_row_group_first td { border-top-width: 2px; }
#mycombinedtable .gt_row_group_first th { border-top-width: 2px; }
#mycombinedtable .gt_striped { background-color: rgba(128,128,128,0.05); }
#mycombinedtable .gt_striped { color: #333333; background-color: #F4F4F4; }
#mycombinedtable .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
#mycombinedtable .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
#mycombinedtable .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
#mycombinedtable .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
#mycombinedtable .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
#mycombinedtable .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
#mycombinedtable .gt_left { text-align: left; }
Expand Down Expand Up @@ -182,8 +185,11 @@
#id1 .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
#id1 .gt_row_group_first td { border-top-width: 2px; }
#id1 .gt_row_group_first th { border-top-width: 2px; }
#id1 .gt_striped { background-color: rgba(128,128,128,0.05); }
#id1 .gt_striped { color: #333333; background-color: #F4F4F4; }
#id1 .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
#id1 .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
#id1 .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
#id1 .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
#id1 .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
#id1 .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
#id1 .gt_left { text-align: left; }
Expand Down Expand Up @@ -256,8 +262,11 @@
#id2 .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
#id2 .gt_row_group_first td { border-top-width: 2px; }
#id2 .gt_row_group_first th { border-top-width: 2px; }
#id2 .gt_striped { background-color: rgba(128,128,128,0.05); }
#id2 .gt_striped { color: #333333; background-color: #F4F4F4; }
#id2 .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
#id2 .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
#id2 .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
#id2 .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
#id2 .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
#id2 .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
#id2 .gt_left { text-align: left; }
Expand Down
30 changes: 30 additions & 0 deletions gt_extras/tests/test_plotting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pandas as pd
import polars as pl
import pytest
from great_tables import GT, loc, style

Expand Down Expand Up @@ -975,6 +976,35 @@ def test_gt_plt_bar_stack_invalid_scale():
gt_plt_bar_stack(gt=gt_test, column="values", scale_type="invalid") # type: ignore


@pytest.mark.xfail(
reason="Will pass when https://github.com/posit-dev/gt-extras/issues/167 is resolved"
)
def test_gt_plt_bar_stack_with_polars_series():
df_dict = {
"team": ["A", "B"],
"values": [
[10, 20, 30],
[40, 30, 20],
],
}

df = pl.DataFrame(df_dict)
gt_test = GT(df)

result = gt_plt_bar_stack(gt=gt_test, column="values")
html = result.as_raw_html()

assert html.count('width="32.0"') == 2
assert html.count('height="30"') == 8
assert html.count("<rect") == 6

assert html.count('height="30" fill="#000000"') == 2
assert html.count('height="30" fill="#25bce6"') == 2
assert html.count('height="30" fill="#9e9e9e"') == 2

assert html.count('<text dominant-baseline="central" text-anchor="middle"') == 6


def test_gt_plt_bar_pct_snap(snapshot, mini_gt):
res = gt_plt_bar_pct(gt=mini_gt, column="num")

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ keywords = ["tables", "html"]
[dependency-groups]
dev = [
"quartodoc>=0.8.1; python_version >= '3.9'",
"great-tables>=0.20.0",
"griffe",
"polars",
"pandas",
Expand Down