pypi great-tables 1.1.0
v1.1.0

4 hours ago

Great Tables v1.1.0 is quite a hefty release, and it's centered on richer color scaling, accessibility, and much more reliable LaTeX output. Tables can now have a stub made of several columns, and the new cols_align_decimal() method lines up numbers on their decimal mark. data_color() gains custom color functions, a midpoint= for diverging scales, row-wise coloring, and perceptually based text contrast (APCA). HTML tables now carry semantic markup for screen readers by default. This release also fixes more than 60 bugs, with most of the fixes in the number formatters (rounding, infinite and missing values) and in LaTeX rendering.

New Features

  • Multi-column stubs — rowname_col= now accepts a list of columns, so the stub can show several levels of row labels. Use the new stub(n) selector in any columns= argument to target one stub level (e.g., cols_width(cases={stub(1): "70px", stub(2): "200px"})). (#861, #933)
  • cols_align_decimal() — Aligns the numeric values in a column on their decimal mark, with optional dec_mark= and locale= settings. (#944)
  • Custom color functions in data_color() — The new fn= argument takes a function that maps a list of values to a list of colors, giving you full control over the color mapping. (#898)
  • Diverging scales with midpoint= — data_color(midpoint=0) centers the palette on a value. The domain is made symmetric around it unless you supply one. (#911)
  • Row-wise coloring — data_color(direction="row") computes colors across each row instead of down each column. (#950)
  • APCA text contrast — The new contrast_algo= argument in data_color() chooses between "apca" (the new default) and "wcag" for automatic text coloring. (#897)
  • Accessible HTML tables — Header cells now have unique ids, and body cells link to them through headers. Stub and row group header cells get scope attributes. Tables are named and described by their title and subtitle (aria-labelledby/aria-describedby). (#936, #957, #959)
  • min_sep_threshold= in number formatters — Sets the minimum number of digits before digit grouping applies, and follows each locale's own minimum grouping digits by default, as in gt. (#956)

Enhancements

  • Images, nanoplots, flags, and icons now get accessible markup (alternative text and roles). (#968)
  • Nanoplot CSS is now scoped to each plot, and the static view (interactive_data_values=False) is less cluttered. (#903)
  • ISO durations from fmt_duration() are now machine-readable, and durations shown as zero no longer carry a sign. (#966)
  • Units notation and fmt_chem() now render in LaTeX output. (#969, #973)
  • The rows= argument of the fmt_*(), sub_*(), and cols_merge*() methods is now typed as RowSelectExpr, which improves editor and type-checker support. (#896)

Behavior Changes

  • data_color() now picks text colors with APCA by default instead of the WCAG contrast ratio, so some cells may get different text colors. Use contrast_algo="wcag" to keep the old behavior. (#897)
  • data_color() palettes are now interpolated in CIELAB, which gives smoother, more perceptually even gradients. Colors between palette stops will differ slightly from earlier versions. (#964)
  • data_color() now uses the declared level order of ordered Pandas Categorical and Polars Enum columns as the inferred domain. (#902)
  • Stub and row group columns are now excluded from column selections, as originally intended. When columns= is omitted, methods target body columns only, so data_color() no longer colors stub cells. loc.body() and cols_move*() raise a clear error when given a stub or group column. (#933)

Deprecations

  • The placeholder= parameter of output_gt() is deprecated. (#909)
  • The islands and airquality datasets are deprecated and now emit a FutureWarning. They will be removed in a future release. (#939)

Bug Fixes

  • When rounding carries over, it now moves into the next exponent, suffix, unit, or prefix. This applies to fmt_scientific() and n_sigfig= (#906), fmt_engineering() (#915), compact numbers (#914), fmt_bytes() (#916), and fmt_number_si() (#918).
  • drop_trailing_zeros= no longer strips zeros from the integer part of a number. (#925)
  • fmt_scientific() keeps trailing zeros with n_sigfig=, as documented. (#963)
  • Negative values are now rounded away from zero, as in R gt. (#953)
  • Values that round to zero are now shown without a sign. (#940)
  • fmt_currency() now handles currency codes that have no minor unit. (#931)
  • Number streams wrapped in brackets (e.g., "[1, 2, 3]") now parse correctly. (#908)
  • fmt_partsper(), fmt_fraction(), fmt_number_si(), and fmt_duration() now follow locales that don't group four-digit numbers. (#970)
  • NaN and infinite values are now handled consistently across the formatters. This includes fmt_scientific(), fmt_engineering(), fmt_bytes(), fmt_roman(), fmt_duration(), fmt_number_si(), n_sigfig=, and compact=True. (#917, #920, #922, #926)
  • Missing values in nullable Pandas columns no longer render as 0. (#949)
  • fmt_fraction(), fmt_roman(), and fmt_index() now format NumPy integer and float32 values. (#958)
  • fmt_tf() now accepts NumPy booleans from Pandas columns. (#921)
  • Pandas columns of PyArrow-backed strings are now auto-aligned. (#900)
  • sub_large_vals(sign="-") now shows the negative threshold. (#913)
  • sub_small_vals() and sub_large_vals() now substitute NumPy scalars and treat booleans and Decimal values consistently. (#946, #967)
  • sub_zero() now skips missing values in nullable Pandas columns and leaves boolean values alone. (#962, #971)
  • A sub_*() call no longer turns off HTML/LaTeX escaping for the cells it skips. PyArrow tables are now escaped too. (#938)
  • fmt_time() now accepts datetime values and the documented YYYY-MM-DD HH:MM:SS strings, and rejects date-only strings. (#919, #930)
  • The year_week date style now uses the week-based year. (#924)
  • In ISO durations, the T designator now comes before the time parts. (#947)
  • In units notation, a slashed unit now has its exponent negated, and inverted first powers are dropped. (#942, #969)
  • data_color() now applies alpha= to gradient palette colors. (#892)
  • data_color() now handles Pandas string columns with pd.NA, scales Decimal values as numbers, and gives infinite values the colors at either end of the palette. (#902)
  • Nanoplots now keep a stroke width of zero, use a separate area pattern for each fill color, and draw reference lines in single-value plots. (#893, #894, #901)
  • Missing values in nanoplots are now handled correctly. (#905)
  • Nanoplot number formatting at range boundaries and for compact currency values is now correct. (#928)
  • fmt_flag() now handles invalid country codes. (#912)
  • In LaTeX output, special characters are now escaped in the fmt_index() pattern, </> characters, summary row labels, and the < of sub-unit durations. (#895, #941, #945, #954)
  • LaTeX: the stubhead label now renders in the column headings, including when it's empty. (#907, #932)
  • LaTeX: sub_*() replacement text now renders, and substitution thresholds are shown compactly. (#934, #941)
  • LaTeX: fmt_currency() symbols are now written as LaTeX-safe characters. (#923)
  • LaTeX: fmt_bytes() now uses the LaTeX minus sign. (#935)
  • LaTeX: exp_style="low-ten" now uses a LaTeX subscript. (#943)
  • LaTeX: fmt_url() and fmt_email() links are now written with \href. (#955)
  • LaTeX: group summary rows with side="top" are now placed at the top of the group. (#948)
  • LaTeX: row groups are now separated by a midrule when row_group_as_column=True. (#951)
  • LaTeX: tab_stub_indent() now indents row labels, including for rem/% lengths and with correct point rounding. (#952, #961)
  • LaTeX: decimal alignment, summary row values, and grouped summary rows now render correctly. (#965)
  • LaTeX tables where a row starts with [ no longer break. (#974)
  • great_tables.data now defines __all__, so star imports no longer overwrite pd/pl. (#937)

Documentation

  • Added an Accessibility page to the User Guide. (#960)
  • Added a correlation matrix example to the gallery. (#857)
  • The as_latex() Limitations list has been updated to match current LaTeX output. (#972)
  • References to formatters that exist in both GT and vals are now fully qualified. (#975)
  • Fixed the Premade Themes link in the opt_stylize() docs. (#976)

Maintenance

  • The nanoplots code was refactored, with many new snapshot tests and a comparison script. Bar plots with x values now raise NotImplementedError instead of erroring. (#904)
  • Internal cleanups: consolidated test helpers, shared rounding-carry and pattern= helpers, a shared dtype helper, and a refactor of column merge display values. (#899, #910, #927, #929, #970)

Contributors

Thank you to everyone who contributed to this release, especially @LuisFigueroaG, @raashish1601, @manan28025, @Rodrigo-Palma, @taekop, @blaahhrrgg, and @naseem173.

Don't miss a new great-tables release

NewReleases is sending notifications on new releases.