diff --git a/blog/bring-your-own-df/index.html b/blog/bring-your-own-df/index.html index 8f8bda734..ed72c732a 100644 --- a/blog/bring-your-own-df/index.html +++ b/blog/bring-your-own-df/index.html @@ -246,7 +246,7 @@

The

The challenge of removing hard dependencies

Removing hard dependencies on DataFrame libraries is worthwhile, but requires special handling for all DataFrame specific actions. To illustrate consider the Great Tables output below, which is produced from a Pandas DataFrame:

-
+
import pandas as pd
 import polars as pl
 from great_tables import GT
@@ -256,51 +256,51 @@ 

GT(df_pandas)

-
+
@@ -336,7 +336,7 @@

Getting column names

The code below shows the different methods required to get column names as a list from Pandas and Polars.

-
+
df_pandas.columns.tolist()  # pandas
 df_polars.columns           # polars
@@ -344,7 +344,7 @@

Getting column names<

Notice that the two lines of code aren’t too different—Pandas just requires an extra .tolist() piece. We could create a special function, that returns a list of names, depending on the type of the input DataFrame.

-
+
def get_column_names(data) -> list[str]:
 
     # pandas specific ----
@@ -371,7 +371,7 @@ 

How we made Pa

Inverting dependency with databackend

Inverting dependency on DataFrame libraries means that we check whether something is a specific type of DataFrame, without using imports. This is done through the package databackend, which we copied into Great Tables.

It works by creating placeholder classes, which stand in for the DataFrames they’re detecting:

-
+
from great_tables._databackend import AbstractBackend
 
 
@@ -400,7 +400,7 @@ 

Inve

Separating concerns with singledispatch

While databackend removes dependencies, the use of singledispatch from the built-in functools module separates out the logic for handling Polars DataFrames from the logic for Pandas DataFrames. This makes it easier to think one DataFrame at a time, and also gets us better type hinting.

Here’s a basic example, showing the get_column_names() function re-written using singledispatch:

-
+
from functools import singledispatch
 
 
@@ -431,7 +431,7 @@ 

Se
  • The use of PdDataFrame is what signifies “run this for Pandas DataFrames”.
  • With the get_column_names implementations defined, we can call it like a normal function:

    -
    +
    get_column_names(df_pandas)  # pandas version
     get_column_names(df_polars)  # polars version
    diff --git a/blog/design-philosophy/index.html b/blog/design-philosophy/index.html index f76775b10..bbf986270 100644 --- a/blog/design-philosophy/index.html +++ b/blog/design-philosophy/index.html @@ -232,53 +232,53 @@

    What is a table, re
  • the data is primarily text
  • Let’s look at an example of a simple table with actual data to tie this theory to practice.

    -
    +
    -
    +

    @@ -442,7 +442,7 @@

    A
  • Table Footer: a place for additional information pertaining to the table content
  • Here’s a table that takes advantage of the different components available in Great Tables. It contains the names and addresses of people.

    -
    +
    Show the code
    from great_tables import GT, md, system_fonts
    @@ -466,51 +466,51 @@ 

    A )

    -
    +

    @@ -612,7 +612,7 @@

    Formatting

  • a compact integer value (fmt_integer()): 134K
  • The problem grows worse when values need to be conveyed as images or plots. If you’re a medical analyst, for example, you might need to effectively convey whether test results for a patient are improving or worsening over time. Reading such data as a sequence of numbers across a row can slow interpretation. But by using nanoplots, available as the fmt_nanoplot() formatting method, readers can spot trends right away. Here’s an example that provides test results over a series of days.

    -
    +
    Show the code
    import great_tables
    @@ -640,51 +640,51 @@ 

    Formatting

    )
    -
    +
    diff --git a/blog/index.html b/blog/index.html index 240337366..1befac634 100644 --- a/blog/index.html +++ b/blog/index.html @@ -261,7 +261,7 @@

    Great Blogposts

    - + @@ -272,7 +272,7 @@

    Great Blogposts

    Michael Chow
    - + @@ -283,7 +283,7 @@

    Great Blogposts

    Rich Iannone and Michael Chow
    - + @@ -294,7 +294,7 @@

    Great Blogposts

    Rich Iannone
    - + @@ -305,7 +305,7 @@

    Great Blogposts

    Rich Iannone
    - + @@ -316,7 +316,7 @@

    Great Blogposts

    Michael Chow
    - + @@ -327,7 +327,7 @@

    Great Blogposts

    Rich Iannone
    - + @@ -338,7 +338,7 @@

    Great Blogposts

    Michael Chow
    - + diff --git a/blog/introduction-0.2.0/index.html b/blog/introduction-0.2.0/index.html index c579cdc10..f168b391b 100644 --- a/blog/introduction-0.2.0/index.html +++ b/blog/introduction-0.2.0/index.html @@ -209,7 +209,7 @@

    Great Tables v0.2.0: Easy Data Coloring

    We enjoy working on Great Tables because we want everybody to easily make beautiful tables. Tables don’t have to be boring, they really could be captivating and insightful. With every release we get closer and closer to realizing our mission and, as such, we’re happy to announce the v0.2.0 release that’s now on PyPI.

    The really big feature that’s available with this release is the data_color() method. It gives you several options for colorizing data cells based on the underlying data. The method automatically scales color values according to the data in order to emphasize differences or reveal trends. The example below emphasizes large currency values with a "darkgreen" fill color.

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -220,51 +220,51 @@ 

    Great Tables v0.2.0: Easy Data Coloring

    ) )
    -
    +
    Apr 24, 2024
    Apr 4, 2024
    Mar 19, 2024
    Feb 16, 2024
    Feb 8, 2024
    Jan 24, 2024
    Jan 8, 2024
    Jan 4, 2024
    @@ -306,7 +306,7 @@

    Great Tables v0.2.0: Easy Data Coloring

    Note that we use columns= to specify which columns get the colorizing treatment (just currency here) and the palette= is given as a list of color values. From this we can see that the 65100.0 value polarizes the data coloring process; it is "darkgreen" while all other values are "lightblue" (with no interpolated colors in between). Also, isn’t it nice that the text adapts to the background color?

    The above example is suitable for emphasizing large values, but, maybe you consider the extreme value to be something that’s out of bounds? For that, we can use the domain= and na_value= arguments to gray-out the extreme values. We’ll also nicely format the currency column in this next example.

    -
    +
    (
         GT(exibble[["currency", "date", "row"]].head(4), rowname_col="row")
         .data_color(
    @@ -322,51 +322,51 @@ 

    Great Tables v0.2.0: Easy Data Coloring

    ) )
    -
    +
    @@ -408,7 +408,7 @@

    Great Tables v0.2.0: Easy Data Coloring

    Now the very large value is in "lightgray", making all other values easier to compare. We did setting domain=[0, 50] and specifying na_color="lightgray". This caused the out-of-bounds value of 65100 to have a light gray background. Notice that the values are also formatted as currencies, and this is thanks to fmt_currency() which never interferes with styling.

    Here’s a more inspirational example that uses a heavily-manipulated version of the countrypops dataset (thanks again, Polars!) along with a color treatment that’s mediated by data_color(). Here, the population values can be easily compared by the amount of "purple" within them.

    -
    +
    from great_tables.data import countrypops
     import polars as pl
     import polars.selectors as cs
    @@ -434,51 +434,51 @@ 

    Great Tables v0.2.0: Easy Data Coloring

    .data_color(palette=["white", "purple"], domain=[0, 1.7e5]) )
    -
    +
    diff --git a/blog/introduction-0.3.0/index.html b/blog/introduction-0.3.0/index.html index 2dba0e29a..1395e785e 100644 --- a/blog/introduction-0.3.0/index.html +++ b/blog/introduction-0.3.0/index.html @@ -222,7 +222,7 @@

    Great Tables v0.3.0: So Many Style Options!

    Modifying the widths of columns

    Before v0.3.0, you could not alter the widths of individual columns. This meant that to great extent your content decided the width of individual columns. Even though browsers do an adequate job in sizing the widths of table columns, it doesn’t always result in a pleasing-to-look-at table. What if you want more space? Maybe you want consistently-sized columns? There’s many reasons to want to have a choice in the matter and the new cols_width() method now makes this possible.

    Here’s an example where the widths of all columns are set with our preferred length values (in px).

    -
    +
    from great_tables import GT, exibble
     
     exibble_mini = exibble[["num", "char", "date", "datetime", "row"]].head(5)
    @@ -239,51 +239,51 @@ 

    Modifying ) )

    -
    +
    @@ -354,7 +354,7 @@

    Modifying

    Setting options across the entire table with tab_options()

    The new tab_options() method gives you the freedom to specify any of dozens of global style and layout options for the table. Want a font that’s used across all cells? Use the table_font_names= option. Do you need to make the text smaller, but only in the stub? Use stub_font_size= for that. The number of options is perhaps overwhelming at first but we think you’ll enjoy having them around nonetheless. It makes styling the table (and developing your own table themes) a relatively simple task.

    Here’s an example that creates a table with a few common components and then uses tab_options() to set up a collection of fonts for the table with the (also new) system_fonts() function:

    -
    +
    from great_tables import md, system_fonts
     
     gt_tbl = (
    @@ -374,51 +374,51 @@ 

    gt_tbl.tab_options(table_font_names=system_fonts(name="industrial"))

    -
    +
    @@ -508,54 +508,54 @@

    system_fonts() helper function in Great Tables makes this easy by providing you with themed, local font stacks that are meant to work across different computing platforms.

    Here’s another example where we set the width of the table to span across the entire page (or containing element).

    -
    +
    gt_tbl.tab_options(table_width="100%")
    -
    +

    @@ -644,54 +644,54 @@

    :

    -
    +
    gt_tbl.tab_options(table_background_color="lightcyan")
    -
    +

    @@ -784,54 +784,54 @@

    Using the new opt_*() methods to do more complex tasks with table options

    While tab_options() is a great method for setting global table options, sometimes you want to set a number of them at once for a combined effect. For that type of operation, we have the opt_*() series of methods. A common thing you might do is align the content in the table header, we can make that an easy thing with opt_align_table_header():

    -
    +
    gt_tbl.opt_align_table_header(align="left")
    -
    +
    @@ -921,54 +921,54 @@

    tab_options() to find the two args you need to get the job done.

    The opt_all_caps() method transforms the text within the column labels, the stub, and in all row groups so that we get an all-capitalized (yet somewhat sized down) look that better differentiates the labels from the data. It’s rather easy to use, just do this:

    -
    +
    gt_tbl.opt_all_caps()
    -
    +

    @@ -1058,54 +1058,54 @@

    tab_options() all at once, making life generally easier.

    Here’s one last example, this time using opt_vertical_padding(). You’d use that if you’re dissatisfied with the level of top/bottom padding within cells of all locations (e.g., in the table body, in the column labels, etc.). You can either make a table taller or more ‘compressed’ with a single argument: scale=. Here’s an example where the amount of vertical padding is reduced, resulting in a table taking up less vertical space.

    -
    +
    gt_tbl.opt_vertical_padding(scale=0.5)
    -
    +

    @@ -1206,7 +1206,7 @@

    A new formatting method: fmt_image()

    Wouldn’t it be great to add graphics to your table? The fmt_image() method provides an easy way to add image files on disk into table body cells. The cells need to contain some reference to an image file. The path= and file_pattern= arguments give you some flexibility in defining exactly where the image files live.

    Here’s an example using the metro dataset that’s included within Great Tables.

    -
    +
    from great_tables.data import metro
     from importlib_resources import files
     
    @@ -1225,51 +1225,51 @@ 

    A new fo .tab_options(table_width="700px") )

    -
    +
    @@ -1282,27 +1282,27 @@

    A new fo

    - + - + - + - + - + diff --git a/blog/introduction-0.4.0/index.html b/blog/introduction-0.4.0/index.html index eee18ad38..76e264d48 100644 --- a/blog/introduction-0.4.0/index.html +++ b/blog/introduction-0.4.0/index.html @@ -218,7 +218,7 @@

    Great Tables v0.4.0: Nanoplots and More

    The recent v0.4.0 release of Great Tables contains nanoplots as a major new feature. So, in this post I’ll concentrate on showing you all the things you can do with nanoplots. What are nanoplots? Well, with nanoplots you can do this:

    -
    +
    Show the code
    from great_tables import GT, md
    @@ -245,51 +245,51 @@ 

    Great Tables v0.4.0: Nanoplots and More

    )
    -
    +
    Argentine 2,079,212
    Bastille 8,069,243
    Bérault 2,106,827
    Champs-Élysées—Clemenceau 1,909,005
    Charles de Gaulle—Étoile 4,291,663
    @@ -367,7 +367,7 @@

    Great Tables v0.4.0: Nanoplots and More

    Nanoplots, small interactive plots in your table

    Nanoplots are small yet information-laden plots that fit nicely into table cells. They are interactive, allowing for more information to be shown on hovering (or through touch when that interaction is available). Nanoplots try to show individual data points with reasonably good visibility (space is limited, this is going in a table after all!) and the plot representations change depending on the data fed into them.

    We can generate nanoplots via the fmt_nanoplot() method. Let’s make two nanoplots of the two different available plot types: "line" and "bar":

    -
    +
    random_numbers_df = pl.DataFrame(
         {
             "i": range(1, 5),
    @@ -386,51 +386,51 @@ 

    .fmt_nanoplot(columns="bars", plot_type="bar") )

    -
    +
    @@ -475,7 +475,7 @@

    Adding reference lines and highlighted areas

    It’s possible to add in a reference line and a reference area to individual plots. These may be useful to highlight a particular statistic (e.g., median or minimum value) or a bounded region of interest (e.g., the area between the first and third quartiles). Here is an example of how to use these options via the reference_line= and reference_area= arguments:

    -
    +
    (
         GT(random_numbers_df, rowname_col="i")
         .fmt_nanoplot(
    @@ -490,51 +490,51 @@ 

    reference_area=["max", "median"]) )

    -
    +
    @@ -579,7 +579,7 @@

    Simple bars

    We can also have single-value bar plots and line plots. These will run in the horizontal direction and such plots are meant for easy value comparisons (which works great in tables). To make this work, give fmt_nanoplot() a column of numeric values. The following example shows how fmt_nanoplot() can be used to create single-value bar and line plots.

    -
    +
    single_vals_df = pl.DataFrame(
         {
             "i": range(1, 6),
    @@ -594,51 +594,51 @@ 

    Simple bars

    .fmt_nanoplot(columns="lines", plot_type="line") )
    -
    +
    @@ -688,7 +688,7 @@

    Simple bars

    Customizing with nanoplot_options()

    We provide a lot of options for customizing your nanoplots. With the nanoplot_options() helper function, it’s possible to change the look and feel for a set of nanoplots. The options= argument of fmt_nanoplot() is where you’d need to invoke that helper function. Some possibilities for customization include determining which nanoplot elements are present, changing the sizes and colors of different elements, and a whole lot more! Here’s an example where both line- and bar-based nanoplots retain their basic compositional elements, but their appearance is quite different.

    -
    +
    from great_tables import nanoplot_options
     
     (
    @@ -719,51 +719,51 @@ 

    Customiz ) )

    -
    +
    diff --git a/blog/introduction_great_tables.html b/blog/introduction_great_tables.html index 0d75984dd..645576fca 100644 --- a/blog/introduction_great_tables.html +++ b/blog/introduction_great_tables.html @@ -232,7 +232,7 @@

    Introducing Great Tables

    A Basic Table

    Let’s get right to making a display table with Great Tables. The package has quite a few datasets and so we’ll start by making use of the very small, but useful, exibble dataset. After importing the GT class and that dataset, we’ll introduce that Pandas table to GT().

    -
    +
    from great_tables import GT, exibble
     
     # Create a display table with the `exibble` dataset
    @@ -241,51 +241,51 @@ 

    A Basic Table

    # Now, show the gt table gt_tbl
    -
    +
    @@ -405,7 +405,7 @@

    A Basic Table

    More Complex Tables

    Let’s take things a bit further and create a table with the included gtcars dataset. Great Tables provides a large selection of methods and they let you refine the table display. They were designed so that you can easily create a really presentable and beautiful table visualization.

    For this next table, we’ll incorporate a Stub component and this provides a place for the row labels. Groupings of rows will be generated through categorical values in a particular column (we just have to cite the column name for that to work). We’ll add a table title and subtitle with tab_header(). The numerical values will be formatted with the fmt_integer() and fmt_currency() methods. Column labels will be enhanced via cols_label() and a source note will be included through use of the tab_source_note() method. Here is the table code, followed by the table itself.

    -
    +
    from great_tables import GT, md, html
     from great_tables.data import gtcars
     
    @@ -424,51 +424,51 @@ 

    More Complex Tables .tab_source_note(source_note="Source: the gtcars dataset within the Great Tables package.") )

    -
    +
    @@ -595,7 +595,7 @@

    More Complex Tables

    With the six different methods applied, the table looks highly presentable! The rendering you’re seeing here has been done through Quarto (this entire site has been generated with quartodoc). If you haven’t yet tried out Quarto, we highly recommend it!

    For this next example we’ll use the airquality dataset (also included in the package; it’s inside the data submodule). With this table, two spanners will be added with the tab_spanner() method. This method is meant to be easy to use, you only need to provide the text for the spanner label and the columns associated with the spanner. We also make it easy to move columns around. You can use cols_move_to_start() (example of that below) and there are also the cols_move_to_end() and cols_move() methods.

    -
    +
    from great_tables.data import airquality
     
     airquality_mini = airquality.head(10).assign(Year=1973)
    @@ -617,51 +617,51 @@ 

    More Complex Tables .cols_move_to_start(columns=["Year", "Month", "Day"]) )

    -
    +

    @@ -810,7 +810,7 @@

    Formatting Table Ce
  • fmt(): set a column format with a formatting function
  • We strive to make formatting a simple task but we also want to provide the user a lot of power through advanced options and we ensure that varied combinations of options works well. For example, most of the formatting methods have a locale= argument. We want as many users as possible to be able to format numbers, dates, and times in ways that are familiar to them and are adapted to their own regional specifications. Now let’s take a look at an example of this with a smaller version of the exibble dataset:

    -
    +
    exibble_smaller = exibble[["date", "time"]].head(4)
     
     (
    @@ -820,51 +820,51 @@ 

    Formatting Table Ce .fmt_time(columns="time", time_style="h_m_s_p") )

    -
    +

    @@ -904,7 +904,7 @@

    Formatting Table Ce

    Using Styles within a Table

    We can use the tab_style() method in combination with loc.body() and various style.*() functions to set styles on cells of data within the table body. For example, the table-making code below applies a yellow background color to the targeted cells.

    -
    +
    from great_tables import GT, style, loc
     from great_tables.data import airquality
     
    @@ -918,51 +918,51 @@ 

    Using Styles w ) )

    -
    +

    @@ -1026,7 +1026,7 @@

    Using Styles w

    Aside from style.fill() we can also use style.text() and style.borders() to focus the styling on cell text and borders. Here’s an example where we perform several types of styling on targeted cells (the key is to put the style.*() calls in a list).

    -
    +
    from great_tables import GT, style, exibble
     
     (
    @@ -1049,51 +1049,51 @@ 

    Using Styles w ) )

    -
    +

    @@ -1148,7 +1148,7 @@

    Using Styles w

    Column Selection with Polars (and How It Helps with Styling)

    Styles can also be specified using Polars expressions. For example, the code below uses the Temp column to set color to "lightyellow" or "lightblue".

    -
    +
    import polars as pl
     
     from great_tables import GT, from_column, style, loc
    @@ -1172,51 +1172,51 @@ 

    ) )

    -
    +

    @@ -1280,7 +1280,7 @@

    +
    import polars.selectors as cs
     
     (
    @@ -1294,51 +1294,51 @@ 

    ) )

    -
    +

    diff --git a/blog/polars-styling/index.html b/blog/polars-styling/index.html index 7e7cd1b99..d30d26431 100644 --- a/blog/polars-styling/index.html +++ b/blog/polars-styling/index.html @@ -222,7 +222,7 @@

    Great Tables: The Polars DataFrame Styler of Your Dreams

    However, there are fewer options for styling tables for presentation. You could convert from polars to pandas, and use the built-in pandas DataFrame styler, but this has one major limitation: you can’t use polars expressions.

    As it turns out, polars expressions make styling tables very straightforward. The same polars code that you would use to select or filter combines with Great Tables to highlight, circle, or bolden text.

    In this post, I’ll show how Great Tables uses polars expressions to make delightful tables, like the one below.

    -
    +
    Code
    import polars as pl
    @@ -277,51 +277,51 @@ 

    Great Tables: The Polars DataFrame Styler of Your Dreams

    )
    -
    +
    @@ -469,7 +469,7 @@

    Th

    Creating GT object

    First, we’ll import the necessary libraries, and do a tiny bit of data processing.

    -
    +
    import polars as pl
     import polars.selectors as cs
     
    @@ -495,56 +495,56 @@ 

    Creating GT object

    The default polars output above is really helpful for data analysis! By passing it to the GT constructor, we can start getting it ready for presentation.

    -
    +
    gt_air = GT(pl_airquality)
     
     gt_air
    -
    +

    @@ -618,7 +618,7 @@

    Creating GT object

    Set title and subtitle

    The simplest method in gt is GT.tab_header(), which lets you add a title and subtitle.

    -
    +
    (
         gt_air
     
    @@ -629,51 +629,51 @@ 

    Set title and subti ) )

    -
    +
    @@ -754,7 +754,7 @@

    Set title and subti

    Set body styles

    The .tab_style() method sets styles—like fill color, or text properties—on different parts of the table. Let’s use it twice with a polars expression. First to highlight the row corresponding to the max Wind value, and then to bold that value.

    -
    +
    from great_tables import style, loc
     
     is_max_wind = pl.col("Wind") == pl.col("Wind").max()
    @@ -776,51 +776,51 @@ 

    Set body styles

    ) )
    -
    +

    @@ -905,7 +905,7 @@

    Set column spannersMore readable labels for columns themselves.

    Use GT.tab_spanner() to set labels on groups of columns.

    -
    +
    time_cols = ["Year", "Month", "Day"]
     
     gt_with_spanners = (
    @@ -924,51 +924,51 @@ 

    Set column spanners gt_with_spanners

    -
    +

    @@ -1047,7 +1047,7 @@

    Set column spanners

    Notice that there are now labels for “Time” and “Measurement” sitting above the column names. This is useful for emphasizing columns that share something in common.

    Use GT.cols_labels() with html() to create human-friendly labels (e.g. convert things like cal_m_2 to cal/m2).

    -
    +
    from great_tables import html
     
     (
    @@ -1060,51 +1060,51 @@ 

    Set column spanners ) )

    -
    +

    @@ -1187,7 +1187,7 @@

    Set column spanners

    Putting it all together

    Finally, we’ll combine everything from the sections above into a single block of code, and use a few more rows of data.

    -
    +
    Code
    import polars as pl
    @@ -1242,51 +1242,51 @@ 

    Putting it all tog )

    -
    +
    diff --git a/blog/superbowl-squares/index.html b/blog/superbowl-squares/index.html index 7c61d5748..b570887e9 100644 --- a/blog/superbowl-squares/index.html +++ b/blog/superbowl-squares/index.html @@ -232,7 +232,7 @@

    What is Super B
  • Away team digit: 7
  • Let’s say you choose the digits above, and write this as 4/7—meaning a final digit of 4 for home and 7 for away. You would mark yourself on this square:

    -
    +
    Code
    df = (
    @@ -256,51 +256,51 @@ 

    What is Super B )

    -
    +

    @@ -477,7 +477,7 @@

    Why analyze squares?

    What squares are most likely to win?

    We looked back at games for the KC Chiefs (away), and games for the San Francisco 49ers (home), and calculated the proportion of the time each team ended with a specific digit. Putting this together for the two teams, here is the chance of winning on a given square:

    -
    +
    Code
    import polars as pl
    @@ -550,51 +550,51 @@ 

    What s )

    -
    +
    @@ -808,7 +808,7 @@

    Method

    Code

    -
    +
    import polars as pl
     import polars.selectors as cs
     from great_tables import GT, md
    @@ -878,51 +878,51 @@ 

    Code

    ) )
    -
    +
    diff --git a/examples/index.html b/examples/index.html index 0a37d1248..b3363b52f 100644 --- a/examples/index.html +++ b/examples/index.html @@ -199,7 +199,7 @@

    Examples

    -
    +
    Show the Code
    import polars as pl
    @@ -226,51 +226,51 @@ 

    Examples

    )
    -
    +
    @@ -349,7 +349,7 @@

    Examples

    -
    +
    Show the Code
    from great_tables import GT, html
    @@ -381,51 +381,51 @@ 

    Examples

    )
    -
    +
    @@ -555,8 +555,8 @@

    Examples

    -
    -
    +
    +
    Show the Code
    from great_tables import GT
    @@ -596,51 +596,51 @@ 

    Examples

    )
    -
    +
    @@ -786,7 +786,7 @@

    Examples

    -
    +
    Show the Code
    from great_tables import GT, html
    @@ -827,51 +827,51 @@ 

    Examples

    )
    -
    +
    @@ -961,7 +961,7 @@

    Examples

    -
    +
    Show the Code
    from great_tables import GT, html
    @@ -992,51 +992,51 @@ 

    Examples

    )
    -
    +
    @@ -1450,53 +1450,53 @@

    Examples

    View source ⬀     Blog post (R code) ⬀

    -
    +
    -
    +
    @@ -1996,6 +1996,272 @@

    Examples

    +
    + +
    + +
    +
    +
    +
    +

    View source ⬀     Notebook ⬀

    +
    +
    +Show the Code +
    import polars as pl
    +import polars.selectors as cs
    +from great_tables import GT, loc, style
    +
    +coffee_sales = pl.read_json("./_data/coffee-sales.json")
    +
    +sel_rev = cs.starts_with("revenue")
    +sel_prof = cs.starts_with("profit")
    +
    +# yo
    +
    +coffee_table = (
    +    GT(coffee_sales)
    +    .tab_header("Sales of Coffee Equipment")
    +    .tab_spanner(label="Revenue", columns=sel_rev)
    +    .tab_spanner(label="Profit", columns=sel_prof)
    +    .cols_label(
    +        revenue_dollars="Amount",
    +        profit_dollars="Amount",
    +        revenue_pct="Percent",
    +        profit_pct="Percent",
    +        monthly_sales="Monthly Sales",
    +        icon="",
    +        product="Product",
    +    )
    +    # formatting ----
    +    .fmt_number(
    +        columns=cs.ends_with("dollars"),
    +        compact=True,
    +        pattern="${x}",
    +        n_sigfig=3,
    +    )
    +    .fmt_percent(columns=cs.ends_with("pct"), decimals=0)
    +    # style ----
    +    .tab_style(
    +        style=style.fill(color="aliceblue"),
    +        locations=loc.body(columns=sel_rev),
    +    )
    +    .tab_style(
    +        style=style.fill(color="papayawhip"),
    +        locations=loc.body(columns=sel_prof),
    +    )
    +    .tab_style(
    +        style=style.text(weight="bold"),
    +        locations=loc.body(rows=pl.col("product") == "Total"),
    +    )
    +    .fmt_nanoplot("monthly_sales", plot_type="bar")
    +    .fmt_image("icon", path="_data/coffee-table-icons/")
    +    .sub_missing(missing_text="")
    +)
    +
    +coffee_table
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Sales of Coffee Equipment
    Product + Revenue + + Profit + Monthly Sales
    AmountPercentAmountPercent
    Grinder$904K3%$568K4%
    7650521494596613667748765686607594568751
    Moka pot$2.05M7%$181K1%
    6.87K04.73K4.74K4.79K5.51K6.16K6.62K6.87K6.03K5.30K4.88K4.65K6.28K
    Cold brew$289K1%$242K2%
    2.70K02442494389811.77K2.70K2.61K2.35K1.74K896499244
    Filter$404K1%$70.0K0%
    2.74K02.07K1.81K1.84K2.12K2.25K2.63K2.56K2.37K2.16K2.19K2.07K2.74K
    Drip machine$2.63M9%$1.37M9%
    2.58K02.14K1.62K1.97K2.10K2.58K2.46K2.34K2.32K2.05K1.97K1.84K2.33K
    AeroPress$2.60M9%$1.29M9%
    9.27K06.33K5.20K6.37K7.02K7.91K8.70K8.69K7.80K6.83K6.96K6.88K9.27K
    Pour over$846K3%$365K2%
    2.18K01.56K1.29K1.51K1.69K1.94K2.18K2.14K1.86K1.72K1.81K1.60K2.16K
    French press$1.11M4%$748K5%
    4.82K03.51K2.88K3.35K3.79K3.90K4.10K4.18K4.43K3.28K3.42K3.30K4.82K
    Cezve$2.51M9%$1.97M13%
    17.1K012.2K11.5K11.8K13.6K15.4K16.5K17.1K14.4K13.0K12.9K11.6K15.9K
    Chemex$3.14M11%$818K6%
    7.22K04.94K4.17K5.24K6.00K6.36K6.77K7.11K6.25K5.60K6.08K4.98K7.22K
    Scale$3.80M13%$2.91M20%
    3.18K01.54K1.57K1.68K2.03K2.42K2.55K2.57K2.23K2.04K2.09K1.69K3.18K
    Kettle$756K3%$618K4%
    1.53K01.14K1.02K1.09K1.13K1.41K1.48K1.46K1.30K1.14K1.23K1.19K1.53K
    Espresso Machine$8.41M29%$3.64M25%
    2.58K06868406185982.15K5337979961.00K6688582.58K
    Total$29.4M102%$14.8M100%
    diff --git a/get-started/basic-column-labels.html b/get-started/basic-column-labels.html index ccf5b15ab..e42ac87aa 100644 --- a/get-started/basic-column-labels.html +++ b/get-started/basic-column-labels.html @@ -341,7 +341,7 @@

    Column Labels

  • Month, Day: the numeric month and day of month for the record
  • We know that all measurements took place in 1973, so a year column will be added to the dataset before it is passed to the GT() class.

    -
    +
    from great_tables import GT, html
     from great_tables.data import airquality
     
    @@ -473,7 +473,7 @@ 

    Column Labels

    Adding Column Spanners

    Let’s organize the time information under a Time spanner label, and put the other columns under a Measurement spanner label. We can do this with the tab_spanner() method.

    -
    +
    gt_airquality = (
         GT(airquality_mini)
         .tab_header(
    @@ -492,51 +492,51 @@ 

    Adding Column Spann gt_airquality

    -
    +
    @@ -674,7 +674,7 @@

    Moving and R
  • customize the column labels so that they are more descriptive (using cols_label())
  • Let’s do both of these things in the next example:

    -
    +
    (
         gt_airquality
         .cols_move_to_start(columns=["Year", "Month", "Day"])
    @@ -686,51 +686,51 @@ 

    Moving and R ) )

    -
    +

    @@ -866,57 +866,57 @@

    Moving and R

    Targeting Columns for columns=

    In the above examples, we selected columns to span or move using a list of column names (as strings). However, Great Tables supports a wide range of ways to select columns.

    For example, you can use a lambda function:

    -
    +
    (
         GT(airquality_mini)
         .cols_move_to_start(columns=lambda colname: colname.endswith("R"))
     )
    -
    +
    diff --git a/get-started/basic-formatting.html b/get-started/basic-formatting.html index 77ec3fb00..e624b6105 100644 --- a/get-started/basic-formatting.html +++ b/get-started/basic-formatting.html @@ -330,7 +330,7 @@

    Formatting Values

    The values within the table body, specifically those within the body cells, can be formatted with a large selection of fmt_*() methods like fmt_number(), fmt_integer(), fmt_scientific(), and more. Let’s use a portion of the exibble dataset and introduce some formatting to the cell values. First, we’ll generate the basic GT object and take a look at the table without any cell formatting applied.

    -
    +
    from great_tables import GT
     from great_tables.data import exibble
     from great_tables import vals
    @@ -339,51 +339,51 @@ 

    Formatting Values

    gt_ex
    -
    +
    @@ -435,56 +435,56 @@

    Formatting Values

    The num column contains both small and much larger numbers. We can use the fmt_number() method to obtain formatted values have a fixed level of decimal precision and grouping separators. At the same time, we’ll format the numeric values in currency column to get monetary values.

    -
    +
    gt_ex = gt_ex.fmt_number(columns="num", decimals=2).fmt_currency(columns="currency")
     
     gt_ex
    -
    +
    @@ -536,7 +536,7 @@

    Formatting Values

    Dates and times can be formatted as well. As long as they are in ISO 8601 form, the fmt_date() and fmt_time() methods can be used to format such values. These methods have corresponding date_style= and time_style= arguments that accept a number of keywords that act as preset formatting styles.

    -
    +
    gt_ex = (
         gt_ex.fmt_date(columns="date", date_style="m_day_year")
         .fmt_time(columns="time", time_style="h_m_p")
    @@ -544,51 +544,51 @@ 

    Formatting Values

    gt_ex
    -
    +
    @@ -640,56 +640,56 @@

    Formatting Values

    It’s possible to format cells that have already been formatted. Using a formatting method again on previously formatted cells will always work within the ‘last-formatted-wins’ rule.

    -
    +
    gt_ex = gt_ex.fmt_date(columns="date", date_style="wday_day_month_year")
     
     gt_ex
    -
    +
    @@ -741,56 +741,56 @@

    Formatting Values

    Within the selected columns= we can choose to target specific cells with the rows= argument. The latter argument allows us to pass in a list of row indices.

    -
    +
    gt_ex = gt_ex.fmt_currency(columns="currency", rows=[2, 3, 4], currency="GBP")
     
     gt_ex
    -
    +
    @@ -853,7 +853,7 @@

    , "fr", "de-AT", etc.) will result in numeric formatting specific to the chosen locale

    Here are a number of examples that use vals.fmt_number().

    -
    +
    fmt_number_1 = vals.fmt_number([1.64, 3.26, 3000.63, 236742.37])
     fmt_number_2 = vals.fmt_number([1.64, 3.26, 3000.63, 236742.37], compact=True)
     fmt_number_3 = vals.fmt_number([1.64, 3.26, 3000.63, 236742.37], decimals=3)
    @@ -870,7 +870,7 @@ 

    vals.fmt_scientific().

    -
    +
    fmt_sci_1 = vals.fmt_scientific([0.00064, 7.353, 863454.63])
     fmt_sci_2 = vals.fmt_scientific([1.64, 3.26, 3000.63], decimals=3)
     fmt_sci_3 = vals.fmt_scientific([1.64, 3.26, 3000.63], exp_style="E")
    @@ -885,7 +885,7 @@ 

    vals.fmt_date() and vals.fmt_time().

    -
    +
    fmt_date_1 = vals.fmt_date(
         ["2015-03-15", "2017-08-18", "2020-04-12"], date_style="wday_month_day_year"
     )
    diff --git a/get-started/basic-header.html b/get-started/basic-header.html
    index baf03812c..1525671ac 100644
    --- a/get-started/basic-header.html
    +++ b/get-started/basic-header.html
    @@ -324,7 +324,7 @@ 

    Header and Footer

    The way that we add components like the Table Header and source notes in the Table Footer is to use the tab_*() family of methods. A Table Header is easy to add so let’s see how the previous table looks with a title and a subtitle. We can add this component using the tab_header() method:

    -
    +
    from great_tables import GT, md, html
     from great_tables.data import islands
     
    @@ -340,51 +340,51 @@ 

    Header and Footer

    ) )
    -
    +

    @@ -451,7 +451,7 @@

    Header and Footer

    The Header table component provides an opportunity to describe the data that’s presented. Using subtitle= allows us to insert a subtitle, which is an optional part of the Header. We may also style the title= and subtitle= using Markdown! We do this by wrapping the values passed to title= or subtitle= with the md() helper function (we may also use html() in a similar fashion). Here is an example with the table data truncated for brevity:

    -
    +
    # Make a display table with the `islands_tbl` table;
     # put a heading just above the column labels
     gt_tbl = (
    @@ -464,51 +464,51 @@ 

    Header and Footer

    gt_tbl
    -
    +
    @@ -543,7 +543,7 @@

    Header and Footer

    A source note can be added to the table’s Footer through use of the tab_source_note() method. It works in the same way as tab_header() (it also allows for Markdown inputs) except it can be called multiple times—each invocation results in the addition of a source note.

    -
    +
    # Display the `islands_tbl` data with a heading and two source notes
     (
         gt_tbl
    @@ -555,51 +555,51 @@ 

    Header and Footer

    ) )
    -
    +
    diff --git a/get-started/basic-stub.html b/get-started/basic-stub.html index f7c8e9eb9..cb63c185b 100644 --- a/get-started/basic-stub.html +++ b/get-started/basic-stub.html @@ -334,7 +334,7 @@

    Stub (Row Labels)

    Row names

    An easy way to generate a Stub part is by specifying a stub column in the GT() class with the rowname_col= argument. This will signal to Great Tables that the named column should be used as the stub, using the contents of that column to make row labels. Let’s add a stub with our islands dataset by using rowname_col= in the call to GT():

    -
    +
    from great_tables import GT, md, html
     from great_tables.data import islands
     
    @@ -342,51 +342,51 @@ 

    Row names

    GT(islands_mini, rowname_col="name")
    -
    +
    @@ -446,57 +446,57 @@

    Row names

    Notice that the landmass names are now placed to the left? That’s the Stub. Notably, there is a prominent border to the right of it but there’s no label above the Stub. We can change this and apply what’s known as a stubhead label through use of the tab_stubhead() method:

    -
    +
    (
         GT(islands_mini, rowname_col="name")
         .tab_stubhead(label="landmass")
     )
    -
    +
    @@ -560,56 +560,56 @@

    Row names

    Row groups

    Let’s incorporate row groups into the display table. This divides rows into groups, creating row groups, and results in a display of a row group labels right above the each group. This can be easily done with a table containing row labels and the key is to use the groupname_col= argument of the GT() class. Here we will create three row groups (with row group labels "continent", "country", and "subregion") to have a grouping of rows.

    -
    +
    island_groups = islands.head(10).assign(group = ["subregion"] * 2 + ["country"] * 2 + ["continent"] * 6)
     
     GT(island_groups, rowname_col="name", groupname_col="group").tab_stubhead(label="landmass")
    -
    +
    diff --git a/get-started/basic-styling.html b/get-started/basic-styling.html index 64cfc202f..0e4516fc7 100644 --- a/get-started/basic-styling.html +++ b/get-started/basic-styling.html @@ -348,7 +348,7 @@

    Stying the Table Body

    Great Tables can add styles—like color, text properties, and borders—on many different parts of the displayed table. The following set of examples shows how to set styles on the body of table, where the data cells are located.

    For the examples on this page, we’ll use the included airquality dataset to set up GT objects for both Pandas and Polars DataFrames.

    -
    +
    import polars as pl
     
     from great_tables import GT, from_column, style, loc
    @@ -362,57 +362,57 @@ 

    Stying the Table Body

    Style basics

    We use the tab_style() method in combination with loc.body() to set styles on cells of data in the table body. For example, the table-making code below applies a yellow background color to specific cells.

    -
    +
    gt_air.tab_style(
         style=style.fill(color="yellow"),
         locations=loc.body(columns="Temp", rows=[1, 2])
     )
    -
    +
    @@ -484,57 +484,57 @@

    Style basics

    Customizing Borders

    Let’s use style.borders() to place borders around targeted cells. In this next example, the table has a red dashed border above two rows.

    -
    +
    gt_air.tab_style(
         style=style.borders(sides="top", color="red", style="dashed", weight="3px"),
         locations=loc.body(rows=[1, 2])
     )
    -
    +
    @@ -601,57 +601,57 @@

    Customizing Borders

    Customizing Text

    We can style text with by using the style.text() function. This gives us many customization possibilities for any text we target. For example, the Solar_R column below has green, bolded text in a custom font.

    -
    +
    gt_air.tab_style(
         style=style.text(color="green", font="Times New Roman", weight="bold"),
         locations=loc.body(columns="Solar_R")
     )
    -
    +
    @@ -719,7 +719,7 @@

    Customizing Text

    Column-based Styles

    In addition to setting styles to specific values (e.g., a "yellow" background fill), you can also use parameter values from table columns to specify styles. The way to do this is to use the from_column() helper function to access those values.

    -
    +
    df = pl.DataFrame({"x": [1, 2], "background": ["lightyellow", "lightblue"]})
     
     (
    @@ -730,51 +730,51 @@ 

    Column-based Styles ) )

    -
    +
    @@ -806,7 +806,7 @@

    Column-based Styles

    Combining Styling with cols_hide()

    One common approach is to specify a style from a column, and then hide that column in the final output. For example, we can add a background column to our airquality data:

    -
    +
    color_map = {
         True: "lightyellow",
         False: "lightblue"
    @@ -891,7 +891,7 @@ 

    Combining

    Notice that the dataset now has a background column set to either "lightyellow" or "lightblue", depending on whether Temp is above 70.

    We can then use this background column to set the fill color of certain body cells, and then hide the background column since we don’t need that in our finalized display table:

    -
    +
    (
         GT(with_color)
         .tab_style(
    @@ -901,51 +901,51 @@ 

    Combining .cols_hide(columns="background") )

    -
    +
    @@ -1017,7 +1017,7 @@

    Combining

    Using Polars expressions

    Styles can also be specified using Polars expressions. For example, the code below uses the Temp column to set color to "lightyellow" or "lightblue".

    -
    +
    # A Polars expression defines color based on `Temp`
     temp_color = (
         pl.when(pl.col("Temp") > 70)
    @@ -1030,51 +1030,51 @@ 

    Using Pol locations=loc.body("Temp") )

    -
    +

    @@ -1142,7 +1142,7 @@

    Using Pol

    Using functions

    You can also use a function, that takes the DataFrame and returns a Series with a style value for each row.

    This is shown below on a pandas DataFrame.

    -
    +
    def map_color(df):
         return (df["Temp"] > 70).map(
             {True: "lightyellow", False: "lightblue"}
    @@ -1154,51 +1154,51 @@ 

    Using functions

    locations=loc.body("Temp") )
    -
    +

    @@ -1268,7 +1268,7 @@

    Specifying col

    Using polars selectors

    If you are using Polars, you can use column selectors and expressions for selecting specific columns and rows:

    -
    +
    import polars.selectors as cs
     
     gt_pl_air.tab_style(
    @@ -1279,51 +1279,51 @@ 

    Using polars select ) )

    -
    +

    @@ -1391,7 +1391,7 @@

    Using polars select

    Using a function

    For tools like pandas, you can use a function (or lambda) to select rows. The function should take a DataFrame, and output a boolean Series.

    -
    +
    gt_air.tab_style(
         style=style.fill(color="yellow"),
         locations=loc.body(
    @@ -1400,51 +1400,51 @@ 

    Using a function

    ) )
    -
    +

    @@ -1512,57 +1512,57 @@

    Using a function

    Multiple styles and locations

    We can use a list within style= to apply multiple styles at once. For example, the code below sets fill and border styles on the same set of body cells.

    -
    +
    gt_air.tab_style(
         style=[style.fill(color="yellow"), style.borders(sides="all")],
         locations=loc.body(columns="Temp", rows=[1, 2]),
     )
    -
    +
    @@ -1626,7 +1626,7 @@

    Multiple sty

    Note that you can also pass a list to locations=!

    -
    +
    gt_air.tab_style(
         style=style.fill(color="yellow"),
         locations=[
    @@ -1635,51 +1635,51 @@ 

    Multiple sty ] )

    -
    +

    @@ -1743,7 +1743,7 @@

    Multiple sty

    You can also combine Polars selectors with a row filtering expression, in order to select a combination of columns and rows.

    -
    +
    import polars.selectors as cs
     
     gt_pl_air.tab_style(
    @@ -1754,51 +1754,51 @@ 

    Multiple sty ) )

    -
    +

    diff --git a/get-started/colorizing-with-data.html b/get-started/colorizing-with-data.html index c8da2edd2..265708bc1 100644 --- a/get-started/colorizing-with-data.html +++ b/get-started/colorizing-with-data.html @@ -334,7 +334,7 @@

    Colorizing with Data

    You sometimes come across heat maps in data visualization, and they’re used to represent data values with color gradients. This technique is great for identifying patterns, trends, outliers, and missing data when there’s lots of data. Tables can have this sort of treatment as well! Typically, formatted numeric values are shown along with some color treatment coinciding with the underlying data values.

    We can make this possible in Great Tables by using the data_color() method. Let’s start with a simple example, using a Polars DataFrame with three columns of values. We can introduce that data to GT() and use data_color() without any arguments.

    -
    +
    from great_tables import GT
     import polars as pl
     
    @@ -348,51 +348,51 @@ 

    Colorizing with Data

    GT(simple_df).data_color()
    -
    +
    @@ -441,54 +441,54 @@

    Colorizing with Data

    Setting palette colors

    While this first example illustrated some basic things, the common thing to do in practices to provide a list of colors to the palette= argument. Let’s choose two colors "green" and "red" and place them in that order.

    -
    +
    GT(simple_df).data_color(palette=["blue", "red"])
    -
    +
    @@ -538,54 +538,54 @@

    Setting palette col

    Coloring missing values with na_color

    There is a lone "None" value in the float column, and it has a gray background. Thoughout the Great Tables package, missing values are treated in different ways and, in this case, it’s given a default color value. We can change that with the na_color= argument. Let’s try it now:

    -
    +
    GT(simple_df).data_color(palette=["blue", "red"], na_color="#FFE4C4")
    -
    +

    @@ -635,7 +635,7 @@

    Colo

    Using domain= to color values across columns

    The previous usages of the data_color() method were such that the color ranges encompassed the boundaries of the data values. That can be changed with the domain= argument, which expects a list of two values (a lower and an upper value). Let’s use the range [0, 10] on the first two columns, integer and float, and not the third (since a numerical domain is incompatible with string-based values). Here’s the table code for that:

    -
    +
    (
         GT(simple_df)
         .data_color(
    @@ -646,51 +646,51 @@ 

    ) )

    -
    +

    @@ -741,7 +741,7 @@

    Bringing it all together

    For a more advanced treatment of data colorization in the table, let’s take the sza dataset (available in the great_tables.data submodule) and vigorously reshape it with Polars so that solar zenith angles are arranged as rows by month, and the half-hourly clock times are the columns (from early morning to solar noon).

    Once the pivot()ing is done, we can introduce that that table to the GT() class, placing the names of the months in the table stub. We will use data_color() with a domain that runs from 90 to 0 (here, 90° is sunrise, and 0° is represents the sun angle that’s directly overhead). There are months where the sun rises later in the morning, before the sunrise times we’ll see missing values in the dataset, and na_color="white" will handle those cases. Okay, that’s the plan, and now here’s the code:

    -
    +
    from great_tables import html
     from great_tables.data import sza
     import polars.selectors as cs
    @@ -767,51 +767,51 @@ 

    Bringing it all t ) )

    -
    +
    diff --git a/get-started/column-selection.html b/get-started/column-selection.html index 42ad347db..7d1e1cc80 100644 --- a/get-started/column-selection.html +++ b/get-started/column-selection.html @@ -340,7 +340,7 @@

    Column Selection

  • a Polars selector.
  • a function that takes a string and returns True or False.
  • -
    +
    from great_tables import GT
     from great_tables.data import exibble
     
    @@ -349,51 +349,51 @@ 

    Column Selection

    gt_ex
    -
    +
    @@ -446,54 +446,54 @@

    Column Selection

    Using integers

    We can use a list of strings or integers to select columns by name or position, respectively.

    -
    +
    gt_ex.cols_move_to_start(columns=["date", 1, -1])
    -
    +
    @@ -554,7 +554,7 @@

    Using integers

    Using Polars selectors

    When using a Polars DataFrame, you can select columns using Polars selectors. The example below uses Polars selectors to move all columns that start with "c" or "f" to the start of the table.

    -
    +
    import polars as pl
     import polars.selectors as cs
     
    @@ -562,51 +562,51 @@ 

    Using Polar GT(pl_df).cols_move_to_start(columns=cs.starts_with("c") | cs.starts_with("f"))

    -
    +
    @@ -657,7 +657,7 @@

    Using Polar

    In general, selection should match the behaviors of the Polars DataFrame.select() method.

    -
    +
    pl_df.select(cs.starts_with("c") | cs.starts_with("f")).columns
    ['char', 'fctr']
    @@ -668,54 +668,54 @@

    Using Polar

    Using functions

    A function can be used to select columns. It should take a column name as a string and return True or False.

    -
    +
    gt_ex.cols_move_to_start(columns=lambda x: "c" in x)
    -
    +

    diff --git a/get-started/index.html b/get-started/index.html index 7ed7a88b1..d585f7c0f 100644 --- a/get-started/index.html +++ b/get-started/index.html @@ -341,65 +341,65 @@

    Let’s Install

    A Basic Table using Great Tables

    Let’s use a subset of the islands dataset available within great_tables.data:

    -
    +
    from great_tables import GT, md, html
     from great_tables.data import islands
     
     islands_mini = islands.head(10)

    The islands data is a simple Pandas DataFrame with 2 columns and that’ll serve as a great start. Speaking of which, the main entry point into the Great Tables API is the GT class. Let’s use that to make a presentable table:

    -
    +
    # Create a display table showing ten of the largest islands in the world
     gt_tbl = GT(islands_mini)
     
     # Show the output table
     gt_tbl
    -
    +
    @@ -463,7 +463,7 @@

    A Basic T

    Some Beautiful Examples

    In the following pages we’ll use Great Tables to turn DataFrames into beautiful tables, like the ones below.

    -
    +
    Show the Code
    from great_tables import GT, md, html
    @@ -487,51 +487,51 @@ 

    Some Beautiful Exa )

    -
    +

    @@ -608,7 +608,7 @@

    Some Beautiful Exa -
    +
    Show the Code
    from great_tables import GT, html
    @@ -636,51 +636,51 @@ 

    Some Beautiful Exa gt_airquality

    -
    +

    diff --git a/get-started/nanoplots.html b/get-started/nanoplots.html index 783019944..0a8dc1992 100644 --- a/get-started/nanoplots.html +++ b/get-started/nanoplots.html @@ -357,7 +357,7 @@

    Nanoplots

    A simple line-based nanoplot

    Let’s make some simple plots with a Polars DataFrame. Here we are using lists to define data values for each cell in the numbers column. The fmt_nanoplot() method understands that these are input values for a line plot (the default type of nanoplot).

    -
    +
    from great_tables import GT
     import polars as pl
     
    @@ -375,51 +375,51 @@ 

    A simple line GT(random_numbers_df).fmt_nanoplot(columns="numbers")

    -
    +
    @@ -480,54 +480,54 @@

    A simple line

    The reference line and the reference area

    You can insert two additional things which may be useful: a reference line and a reference area. You can define them either through literal values or via keywords (these are: "mean", "median", "min", "max", "q1", "q3", "first", or "last"). Here’s a reference line that corresponds to the mean data value of each nanoplot:

    -
    +
    GT(random_numbers_df).fmt_nanoplot(columns="numbers", reference_line="mean")
    -
    +

    @@ -563,54 +563,54 @@

    This example uses a reference area that bounds the minimum value to the median value:

    -
    +
    GT(random_numbers_df).fmt_nanoplot(columns="numbers", reference_area=["min", "median"])
    -
    +

    @@ -650,54 +650,54 @@

    Using autoscale= to have a common y-axis scale across plots

    There are lots of options. Like, if you want to ensure that the scale is shared across all of the nanoplots (so you can better get a sense of overall magnitude), you can set autoscale= to True:

    -
    +
    GT(random_numbers_df).fmt_nanoplot(columns="numbers", autoscale=True)
    -
    +

    @@ -737,7 +737,7 @@

    Using the nanoplot_options() helper function

    There are many options for customization. You can radically change the look of a collection of nanoplots with the nanoplot_options() helper function. With that function, you invoke it in the options= argument of fmt_nanoplot(). You can modify the sizes and colors of different elements, decide which elements are even present, and much more! Here’s an example where a line-based nanoplot retains all of its elements, but the overall appearance is greatly altered.

    -
    +
    from great_tables import nanoplot_options
     
     (
    @@ -758,51 +758,51 @@ 

    ) )

    -
    +
    @@ -842,54 +842,54 @@

    Making nanoplots with bars using plot_type="bar"

    We don’t just support line plots in fmt_nanoplot(), we also have the option to show bar plots. The only thing you need to change is the value of plot_type= argument to "bar":

    -
    +
    GT(random_numbers_df).fmt_nanoplot(columns="numbers", plot_type="bar")
    -
    +
    @@ -926,7 +926,7 @@

    still allows us to supply a reference line and a reference area with reference_line= and reference_area=. The autoscale= option works here as well. We also have a set of options just for bar plots available inside nanoplot_options(). Here’s an example where we use all of the aforementioned customization possibilities:

    -
    +
    (
         GT(random_numbers_df)
         .fmt_nanoplot(
    @@ -949,51 +949,51 @@ 

    ) )

    -
    +

    @@ -1032,7 +1032,7 @@

    Horizontal bar and line plots

    Single-value bar plots, running in the horizontal direction, can be made by simply invoking fmt_nanoplot() on a column of numeric values. These plots are meant for comparison across rows so the method automatically scales the horizontal bars to facilitate this type of display. Here’s a simple example that uses plot_type="bar" on the numbers column that contains a single numeric value in every cell.

    -
    +
    single_vals_df = pl.DataFrame(
         {
             "example": ["Row " + str(x) for x in range(1, 5)],
    @@ -1042,51 +1042,51 @@ 

    Horizontal b GT(single_vals_df).fmt_nanoplot(columns="numbers", plot_type="bar")

    -
    +
    @@ -1122,54 +1122,54 @@

    Horizontal b

    This, interestingly enough, works with the "line" type of nanoplot. The result is akin to a lollipop plot:

    -
    +
    GT(single_vals_df).fmt_nanoplot(columns="numbers")
    -
    +

    @@ -1209,7 +1209,7 @@

    Horizontal b

    Line plots with paired x and y values

    Aside from a single stream of y values, we can plot pairs of x and y values. This works only for the "line" type of plot. We can set up a column of Polars struct values in a DataFrame to have this input data prepared for fmt_nanoplot(). Notice that the dictionary values in the enclosed list must have the "x" and "y" keys. Further to this, the list lengths for each of "x" and "y" must match (i.e., to make valid pairs of x and y).

    -
    +
    weather_2 = pl.DataFrame(
         {
             "station": ["Station " + str(x) for x in range(1, 4)],
    @@ -1244,51 +1244,51 @@ 

    Line ) )

    -
    +

    diff --git a/get-started/row-selection.html b/get-started/row-selection.html index e23e27cd7..df5c0367d 100644 --- a/get-started/row-selection.html +++ b/get-started/row-selection.html @@ -341,7 +341,7 @@

    Row Selection

  • a function that takes a DataFrame and returns a boolean Series.
  • The following sections will use a subset of the exibble data, to demonstrate these options.

    -
    +
    from great_tables import GT, exibble, loc, style
     
     lil_exibble = exibble[["num", "char", "currency"]].head(3)
    @@ -350,54 +350,54 @@ 

    Row Selection

    Using integers

    Use a single integer, or a list of integers, to select rows by position.

    -
    +
    gt_ex.fmt_currency("currency", rows=0, decimals=1)
    -
    +
    @@ -434,54 +434,54 @@

    Using integers

    Notice that a dollar sign ($) was only added to the first row (index 0 in python).

    Indexing works the same as selecting items from a python list. This negative integers select relative to the final row.

    -
    +
    gt_ex.fmt_currency("currency", rows=[0, -1], decimals=1)
    -
    +
    @@ -521,58 +521,58 @@

    Using integers

    Using polars expressions

    The rows= argument accepts polars expressions, which return a boolean Series, indicating which rows to operate on.

    For example, the code below only formats the num column, but only when currency is less than 40.

    -
    +
    import polars as pl
     
     gt_polars = GT(pl.from_pandas(lil_exibble))
     
     gt_polars.fmt_integer("num", rows=pl.col("currency") < 40)
    -
    +
    @@ -608,7 +608,7 @@

    Using polars expr

    Here’s a more realistic example, which highlights the row with the highest value for currency.

    -
    +
    import polars.selectors as cs
     
     gt_polars.tab_style(
    @@ -619,51 +619,51 @@ 

    Using polars expr ) )

    -
    +

    @@ -703,54 +703,54 @@

    Using polars expr

    Using a function

    Since libraries like pandas don’t have lazy expressions, the rows= argument also accepts a function for selecting rows. The function should take a DataFrame and return a boolean series.

    Here’s the same example as the previous polars section, but with pandas data, and a lamba for selecting rows.

    -
    +
    gt_ex.fmt_integer("num", rows=lambda D: D["currency"] < 40)
    -
    +
    @@ -786,7 +786,7 @@

    Using a function

    Here’s the styling example from the previous polars section.

    -
    +
    import polars.selectors as cs
     
     gt_ex.tab_style(
    @@ -797,51 +797,51 @@ 

    Using a function

    ) )
    -
    +
    diff --git a/get-started/table-theme-options.html b/get-started/table-theme-options.html index 792e6b704..a495c7f29 100644 --- a/get-started/table-theme-options.html +++ b/get-started/table-theme-options.html @@ -344,7 +344,7 @@

    Table Theme Options

    This page covers how to style and theme your table using GT.tab_options(), which is meant to quickly set a broad range of styles. In the future, even more granular options will become available via GT.tab_style().

    We’ll use the basic GT object below for most examples, since it marks some of the table parts.

    -
    +
    from great_tables import GT, exibble
     
     gt_ex = (
    @@ -356,51 +356,51 @@ 

    Table Theme Options

    gt_ex
    -
    +
    @@ -498,7 +498,7 @@

    Table Theme Options

    Table option parts

    As the graph above showed, tables are made of many parts—such as the heading, column labels, and stub. .tab_options() organizes options based on table part.

    The code below illustrates the table parts .tab_options() can target, by setting the background color for various parts.

    -
    +
    (
         gt_ex
         .tab_options(
    @@ -512,51 +512,51 @@ 

    Table option parts

    ) )
    -
    +
    @@ -689,58 +689,58 @@

    Findin

    Styling borders

    Many table parts support customizing border colors and style. This is shown below for column labels.

    -
    +
    gt_ex.tab_options(
         column_labels_border_top_color="blue",
         column_labels_border_top_style="solid",
         column_labels_border_top_width="5px"
     )
    -
    +

    @@ -837,56 +837,56 @@

    Styling borders

    Styling background color

    -
    +
    gt_ex.tab_options(
         heading_background_color="purple"
     )
    -
    +
    @@ -985,58 +985,58 @@

    Styling backgroun

    Styling body cells

    The table body can style the lines between individual cells. Use the hline and vline option types to specify cell line color, style, and width.

    For example, the code below changes horizontal lines (hline) between cells to be red, dashed lines.

    -
    +
    gt_ex.tab_options(
         table_body_hlines_color="red",
         table_body_hlines_style="dashed",
         table_body_hlines_width="4px",
     )
    -
    +
    @@ -1131,57 +1131,57 @@

    Styling body cells

    In order to define the vertical lines between cells, set vline styles. For example, the code below makes both horizontal and vertical lines between cells solid.

    -
    +
    gt_ex.tab_options(
         table_body_hlines_style="solid",
         table_body_vlines_style="solid",
     )
    -
    +
    @@ -1279,7 +1279,7 @@

    Styling body cells

    Set options across table parts

    Some options starting with table_ apply to all parts of the table. For example, fonts and background color apply everywhere.

    -
    +
    gt_ex.tab_options(
         table_background_color="green",
         table_font_color="darkblue",
    @@ -1287,51 +1287,51 @@ 

    Set options table_font_names="Times New Roman" )

    -
    +
    @@ -1426,57 +1426,57 @@

    Set options

    Options set across the whole table, can be overriden by styling a specific part.

    -
    +
    gt_ex.tab_options(
         table_background_color="orange",
         heading_background_color="pink"
     )
    -
    +

    @@ -1575,7 +1575,7 @@

    Set options

    A basic theme

    Based on the sections above, we can design an overall theme for a table.

    This requires setting a decent number of options, but makes a big difference when presenting a table! Below is a table with a simple, blue theme. (The code is hidden by default, but can be expanded to see all the options set).

    -
    +
    Code
    from great_tables import GT, exibble
    @@ -1622,51 +1622,51 @@ 

    A basic theme

    )
    -
    +
    diff --git a/get-started/table-theme-premade.html b/get-started/table-theme-premade.html index 4c1f1a16b..04ac431a9 100644 --- a/get-started/table-theme-premade.html +++ b/get-started/table-theme-premade.html @@ -343,7 +343,7 @@

    Premade Themes

  • The remaining GT.opt_*() methods: shortcuts for common uses of GT.tab_options().
  • We’ll use the basic GT object below for most examples, since it marks some of the table parts.

    -
    +
    from great_tables import GT, exibble
     
     lil_exibble = exibble.head(5)[["num", "char", "row", "group"]]
    @@ -357,51 +357,51 @@ 

    Premade Themes

    gt_ex
    -
    +
    @@ -470,54 +470,54 @@

    opt_styli

    Below are the first two premade styles. The first uses color="blue", and the second uses color="red".

    -
    +
    gt_ex.opt_stylize(style = 1, color = "blue")
    -
    +

    @@ -583,54 +583,54 @@

    opt_styli
    -
    +
    gt_ex.opt_stylize(style = 2, color = "red")
    -
    +

    @@ -704,54 +704,54 @@

    opt_*()This section shows the different GT.opt_*() methods available. They serve as convenience methods for common GT.tab_options() tasks.

    Align table header

    -
    +
    gt_ex.opt_align_table_header(align="left")
    -
    +

    @@ -818,54 +818,54 @@

    Align table header

    Make text ALL CAPS

    -
    +
    gt_ex.opt_all_caps()
    -
    +
    @@ -932,54 +932,54 @@

    Make text ALL CAPS

    Reduce or expand padding

    -
    +
    gt_ex.opt_vertical_padding(scale=0.3)
    -
    +
    @@ -1043,54 +1043,54 @@

    Reduce or expand -
    +
    gt_ex.opt_horizontal_padding(scale=3)
    -
    +

    @@ -1157,54 +1157,54 @@

    Reduce or expand

    Set table outline

    -
    +
    gt_ex.opt_table_outline()
    -
    +

    diff --git a/reference/GT.as_raw_html.html b/reference/GT.as_raw_html.html index 1328a7b96..3b4c9cf74 100644 --- a/reference/GT.as_raw_html.html +++ b/reference/GT.as_raw_html.html @@ -242,12 +242,12 @@

    Returns

    Examples:

    Let’s use the row column of exibble dataset to create a table. With the as_raw_html() method, we’re able to output the HTML content.

    -
    +
    from great_tables import GT, exibble
     
     GT(exibble[["row"]]).as_raw_html()
    -
    '<div id="qpvkwvtyfn" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">\n<style>\n#qpvkwvtyfn table {\n          font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen, Ubuntu, Cantarell, \'Helvetica Neue\', \'Fira Sans\', \'Droid Sans\', Arial, sans-serif;\n          -webkit-font-smoothing: antialiased;\n          -moz-osx-font-smoothing: grayscale;\n        }\n\n#qpvkwvtyfn thead, tbody, tfoot, tr, td, th { border-style: none; }\n tr { background-color: transparent; }\n#qpvkwvtyfn p { margin: 0; padding: 0; }\n #qpvkwvtyfn .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }\n #qpvkwvtyfn .gt_caption { padding-top: 4px; padding-bottom: 4px; }\n #qpvkwvtyfn .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }\n #qpvkwvtyfn .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }\n #qpvkwvtyfn .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\n #qpvkwvtyfn .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }\n #qpvkwvtyfn .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\n #qpvkwvtyfn .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }\n #qpvkwvtyfn .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }\n #qpvkwvtyfn .gt_column_spanner_outer:first-child { padding-left: 0; }\n #qpvkwvtyfn .gt_column_spanner_outer:last-child { padding-right: 0; }\n #qpvkwvtyfn .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }\n #qpvkwvtyfn .gt_spanner_row { border-bottom-style: hidden; }\n #qpvkwvtyfn .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }\n #qpvkwvtyfn .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }\n #qpvkwvtyfn .gt_from_md> :first-child { margin-top: 0; }\n #qpvkwvtyfn .gt_from_md> :last-child { margin-bottom: 0; }\n #qpvkwvtyfn .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }\n #qpvkwvtyfn .gt_stub { 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; }\n #qpvkwvtyfn .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; }\n #qpvkwvtyfn .gt_row_group_first td { border-top-width: 2px; }\n #qpvkwvtyfn .gt_row_group_first th { border-top-width: 2px; }\n #qpvkwvtyfn .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; }\n #qpvkwvtyfn .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; }\n #qpvkwvtyfn .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }\n #qpvkwvtyfn .gt_left { text-align: left; }\n #qpvkwvtyfn .gt_center { text-align: center; }\n #qpvkwvtyfn .gt_right { text-align: right; font-variant-numeric: tabular-nums; }\n #qpvkwvtyfn .gt_font_normal { font-weight: normal; }\n #qpvkwvtyfn .gt_font_bold { font-weight: bold; }\n #qpvkwvtyfn .gt_font_italic { font-style: italic; }\n #qpvkwvtyfn .gt_super { font-size: 65%; }\n #qpvkwvtyfn .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }\n #qpvkwvtyfn .gt_asterisk { font-size: 100%; vertical-align: 0; }\n \n</style>\n<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">\n\n<tr class="gt_col_headings">\n  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="row">row</th>\n</tr>\n<tbody class="gt_table_body">\n  <tr>\n    <td class="gt_row gt_left">row_1</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_2</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_3</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_4</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_5</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_6</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_7</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_8</td>\n  </tr>\n</tbody>\n\n\n</table>\n\n</div>\n        '
    +
    '<div id="mrmlkjyjkb" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">\n<style>\n#mrmlkjyjkb table {\n          font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen, Ubuntu, Cantarell, \'Helvetica Neue\', \'Fira Sans\', \'Droid Sans\', Arial, sans-serif;\n          -webkit-font-smoothing: antialiased;\n          -moz-osx-font-smoothing: grayscale;\n        }\n\n#mrmlkjyjkb thead, tbody, tfoot, tr, td, th { border-style: none; }\n tr { background-color: transparent; }\n#mrmlkjyjkb p { margin: 0; padding: 0; }\n #mrmlkjyjkb .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }\n #mrmlkjyjkb .gt_caption { padding-top: 4px; padding-bottom: 4px; }\n #mrmlkjyjkb .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }\n #mrmlkjyjkb .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }\n #mrmlkjyjkb .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\n #mrmlkjyjkb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }\n #mrmlkjyjkb .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\n #mrmlkjyjkb .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }\n #mrmlkjyjkb .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }\n #mrmlkjyjkb .gt_column_spanner_outer:first-child { padding-left: 0; }\n #mrmlkjyjkb .gt_column_spanner_outer:last-child { padding-right: 0; }\n #mrmlkjyjkb .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }\n #mrmlkjyjkb .gt_spanner_row { border-bottom-style: hidden; }\n #mrmlkjyjkb .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }\n #mrmlkjyjkb .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }\n #mrmlkjyjkb .gt_from_md> :first-child { margin-top: 0; }\n #mrmlkjyjkb .gt_from_md> :last-child { margin-bottom: 0; }\n #mrmlkjyjkb .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }\n #mrmlkjyjkb .gt_stub { 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; }\n #mrmlkjyjkb .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; }\n #mrmlkjyjkb .gt_row_group_first td { border-top-width: 2px; }\n #mrmlkjyjkb .gt_row_group_first th { border-top-width: 2px; }\n #mrmlkjyjkb .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; }\n #mrmlkjyjkb .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; }\n #mrmlkjyjkb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }\n #mrmlkjyjkb .gt_left { text-align: left; }\n #mrmlkjyjkb .gt_center { text-align: center; }\n #mrmlkjyjkb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }\n #mrmlkjyjkb .gt_font_normal { font-weight: normal; }\n #mrmlkjyjkb .gt_font_bold { font-weight: bold; }\n #mrmlkjyjkb .gt_font_italic { font-style: italic; }\n #mrmlkjyjkb .gt_super { font-size: 65%; }\n #mrmlkjyjkb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }\n #mrmlkjyjkb .gt_asterisk { font-size: 100%; vertical-align: 0; }\n \n</style>\n<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">\n\n<tr class="gt_col_headings">\n  <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="row">row</th>\n</tr>\n<tbody class="gt_table_body">\n  <tr>\n    <td class="gt_row gt_left">row_1</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_2</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_3</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_4</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_5</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_6</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_7</td>\n  </tr>\n  <tr>\n    <td class="gt_row gt_left">row_8</td>\n  </tr>\n</tbody>\n\n\n</table>\n\n</div>\n        '
    diff --git a/reference/GT.cols_align.html b/reference/GT.cols_align.html index 0261a7dc5..070d3f48d 100644 --- a/reference/GT.cols_align.html +++ b/reference/GT.cols_align.html @@ -257,7 +257,7 @@

    Returns

    Examples

    Let’s use the countrypops to create a small table. We can change the alignment of the population column with cols_align(). In this example, the column label and body cells of population will be aligned to the left.

    -
    +
    from great_tables import GT
     from great_tables.data import countrypops
     
    @@ -270,51 +270,51 @@ 

    Examples

    .cols_align(align="left", columns="population") )
    -
    +
    diff --git a/reference/GT.cols_hide.html b/reference/GT.cols_hide.html index dcbf03a10..c2401b3b3 100644 --- a/reference/GT.cols_hide.html +++ b/reference/GT.cols_hide.html @@ -252,7 +252,7 @@

    Returns

    Examples

    For this example, we’ll use a portion of the countrypops dataset to create a simple table. Let’s hide the year column with the cols_hide() method.

    -
    +
    from great_tables import GT
     from great_tables.data import countrypops
     
    @@ -262,51 +262,51 @@ 

    Examples

    GT(countrypops_mini).cols_hide(columns="year")
    -
    +
    diff --git a/reference/GT.cols_label.html b/reference/GT.cols_label.html index da563e328..eafb65590 100644 --- a/reference/GT.cols_label.html +++ b/reference/GT.cols_label.html @@ -252,7 +252,7 @@

    Returns

    Examples

    Let’s use a portion of the countrypops dataset to create a table. We can relabel all the table’s columns with the cols_label() method to improve its presentation. In this simple case we are supplying the name of the column as the key, and the label text as the value.

    -
    +
    from great_tables import GT
     from great_tables.data import countrypops
     
    @@ -269,51 +269,51 @@ 

    Examples

    ) )
    -
    +
    @@ -359,7 +359,7 @@

    Examples

    We can also use Markdown formatting for the column labels. In this example, we’ll use md("*Population*") to make the label italicized.

    -
    +
    from great_tables import GT, md
     from great_tables.data import countrypops
     
    @@ -372,51 +372,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.cols_move.html b/reference/GT.cols_move.html index a4ec57242..3795e1311 100644 --- a/reference/GT.cols_move.html +++ b/reference/GT.cols_move.html @@ -258,7 +258,7 @@

    Returns

    Examples

    Let’s use the countrypops dataset to create a table. We’ll choose to position the population column after the country_name column by using the cols_move() method.

    -
    +
    from great_tables import GT
     from great_tables.data import countrypops
     
    @@ -274,51 +274,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.cols_move_to_end.html b/reference/GT.cols_move_to_end.html index efbbcfe67..f83012ec9 100644 --- a/reference/GT.cols_move_to_end.html +++ b/reference/GT.cols_move_to_end.html @@ -251,7 +251,7 @@

    Returns

    Examples

    For this example, we’ll use a portion of the countrypops dataset to create a simple table. Let’s move the year column, which is the middle column, to the end of the column series with the cols_move_to_end() method.

    -
    +
    from great_tables import GT
     from great_tables.data import countrypops
     
    @@ -261,51 +261,51 @@ 

    Examples

    GT(countrypops_mini).cols_move_to_end(columns="year")
    -
    +
    @@ -351,54 +351,54 @@

    Examples

    We can also move multiple columns at a time. With the same countrypops-based table (countrypops_mini), let’s move both the year and country_name columns to the end of the column series.

    -
    +
    GT(countrypops_mini).cols_move_to_end(columns=["year", "country_name"])
    -
    +
    diff --git a/reference/GT.cols_move_to_start.html b/reference/GT.cols_move_to_start.html index bc8ad8d3a..57398ccbf 100644 --- a/reference/GT.cols_move_to_start.html +++ b/reference/GT.cols_move_to_start.html @@ -252,7 +252,7 @@

    Returns

    Examples

    For this example, we’ll use a portion of the countrypops dataset to create a simple table. Let’s move the year column, which is the middle column, to the start of the column series with the cols_move_to_start() method.

    -
    +
    from great_tables import GT
     from great_tables.data import countrypops
     
    @@ -262,51 +262,51 @@ 

    Examples

    GT(countrypops_mini).cols_move_to_start(columns="year")
    -
    +
    @@ -352,54 +352,54 @@

    Examples

    We can also move multiple columns at a time. With the same countrypops-based table (countrypops_mini), let’s move both the year and population columns to the start of the column series.

    -
    +
    GT(countrypops_mini).cols_move_to_start(columns=["year", "population"])
    -
    +
    diff --git a/reference/GT.cols_width.html b/reference/GT.cols_width.html index 27cdf38e7..71dbd9476 100644 --- a/reference/GT.cols_width.html +++ b/reference/GT.cols_width.html @@ -251,7 +251,7 @@

    Returns

    Examples

    Let’s use select columns from the exibble dataset to create a new table. We can specify the widths of columns with cols_width(). This is done by specifying the exact widths for table columns in a dictionary. In this example, we’ll set the width of the num column to "150px", the char column to "100px", the date column to "300px". All other columns won’t be affected (their widths will be automatically set by their content).

    -
    +
    from great_tables import GT, exibble
     
     exibble_mini = exibble[["num", "char", "date", "datetime", "row"]].head(5)
    @@ -267,51 +267,51 @@ 

    Examples

    ) )
    -
    +
    @@ -377,7 +377,7 @@

    Examples

    We can also specify the widths of columns as percentages. In this example, we’ll set the width of the num column to "20%", the char column to "10%", and the date column to "30%". Note that the percentages are relative and don’t need to sum to 100%.

    -
    +
    (
         GT(exibble_mini)
         .cols_width(
    @@ -389,51 +389,51 @@ 

    Examples

    ) )
    -
    +
    @@ -499,7 +499,7 @@

    Examples

    We can also mix and match pixel and percentage widths. In this example, we’ll set the width of the num column to "150px", the char column to "10%", and the date column to "30%".

    -
    +
    (
         GT(exibble_mini)
         .cols_width(
    @@ -511,51 +511,51 @@ 

    Examples

    ) )
    -
    +
    @@ -621,7 +621,7 @@

    Examples

    If we set the width of all columns, the table will be forced to use the specified widths (i.e., a column width less than the content width will be honored). In this next example, we’ll set widths for all columns. This is a good way to ensure that the widths you specify are fully respected (and not overridden by automatic width calculations).

    -
    +
    (
         GT(exibble_mini)
         .cols_width(
    @@ -635,51 +635,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.data_color.html b/reference/GT.data_color.html index d806a70d1..b7d13a17b 100644 --- a/reference/GT.data_color.html +++ b/reference/GT.data_color.html @@ -557,56 +557,56 @@

    Examples

    The data_color() method can be used without any supplied arguments to colorize a table. Let’s do this with the exibble dataset:

    -
    +
    import great_tables as gt
     
     gt.GT(gt.data.exibble).data_color()
    -
    +
    @@ -722,57 +722,57 @@

    Examples

    What’s happened is that data_color() applies background colors to all cells of every column with the palette of eight colors. Numeric columns will use ‘numeric’ methodology for color scaling whereas string-based columns will use the ‘factor’ methodology. The text color undergoes an automatic modification that maximizes contrast (since autocolor_text=True by default).

    We can target specific colors and apply color to just those columns. Let’s do that and also supply palette= values of "red" and "green".

    -
    +
    gt.GT(gt.data.exibble).data_color(
         columns=["num", "currency"],
         palette=["red", "green"]
     )
    -
    +
    @@ -888,7 +888,7 @@

    Examples

    With those options in place we see that only the numeric columns num and currency received color treatments. Moreover, the palette colors were mapped to the lower and upper limits of the data in each column; interpolated colors were used for the values in between the numeric limits of the two columns.

    We can manually set the limits of the data with the domain= argument (which is preferable in most cases). Let’s colorize just the currency column and set domain=[0, 50]. Any values that are either missing or lie outside of the domain will be colorized with the na_color= color (so we’ll set that to "lightgray").

    -
    +
    gt.GT(gt.data.exibble).data_color(
         columns="currency",
         palette=["red", "green"],
    @@ -896,51 +896,51 @@ 

    Examples

    na_color="lightgray" )
    -
    +
    diff --git a/reference/GT.fmt.html b/reference/GT.fmt.html index 33c679405..e482d0c68 100644 --- a/reference/GT.fmt.html +++ b/reference/GT.fmt.html @@ -270,7 +270,7 @@

    Returns

    Examples

    Let’s use the exibble dataset to create a table. With the fmt() method, we’ll add a prefix ^ and a suffix $ to the row and group columns.

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -278,51 +278,51 @@ 

    Examples

    .fmt(lambda x: f"^{x}$", columns=["row", "group"]) )
    -
    +
    diff --git a/reference/GT.fmt_bytes.html b/reference/GT.fmt_bytes.html index 9d1e67f81..b8e73f8d4 100644 --- a/reference/GT.fmt_bytes.html +++ b/reference/GT.fmt_bytes.html @@ -336,7 +336,7 @@

    Adapt

    Examples

    Let’s use a single column from the exibble dataset and create a new table. We’ll format the num column to display as byte sizes in the decimal standard through use of the fmt_bytes() method.

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -344,51 +344,51 @@ 

    Examples

    .fmt_bytes(columns="num", standard="decimal") )
    -
    +

    diff --git a/reference/GT.fmt_currency.html b/reference/GT.fmt_currency.html index 437233e8f..b0f91a95c 100644 --- a/reference/GT.fmt_currency.html +++ b/reference/GT.fmt_currency.html @@ -351,7 +351,7 @@

    Adapt

    Examples

    Let’s use the exibble dataset to create a table. With the fmt_currency() method, we’ll format the currency column to display monetary values.

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -363,51 +363,51 @@ 

    Examples

    ) )
    -
    +

    diff --git a/reference/GT.fmt_date.html b/reference/GT.fmt_date.html index ecb0dec8a..92869046e 100644 --- a/reference/GT.fmt_date.html +++ b/reference/GT.fmt_date.html @@ -383,7 +383,7 @@

    Adapt

    Examples

    Let’s use the exibble dataset to create a simple, two-column table (keeping only the date and time columns). With the fmt_date() method, we’ll format the date column to display dates formatted with the "month_day_year" date style.

    -
    +
    from great_tables import GT, exibble
     
     exibble_mini = exibble[["date", "time"]]
    @@ -393,51 +393,51 @@ 

    Examples

    .fmt_date(columns="date", date_style="month_day_year") )
    -
    +

    diff --git a/reference/GT.fmt_datetime.html b/reference/GT.fmt_datetime.html index 9430a4e7a..cdc15315c 100644 --- a/reference/GT.fmt_datetime.html +++ b/reference/GT.fmt_datetime.html @@ -414,7 +414,7 @@

    Returns

    Examples

    Let’s use the exibble dataset to create a simple, two-column table (keeping only the date and time columns). With the fmt_datetime() method, we’ll format the date column to display dates formatted with the "month_day_year" date style and the time column to display times formatted with the "h_m_s_p" time style.

    -
    +
    from great_tables import GT, exibble
     
     exibble_mini = exibble[["date", "time"]]
    @@ -428,51 +428,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.fmt_image.html b/reference/GT.fmt_image.html index a7f28587d..93b436def 100644 --- a/reference/GT.fmt_image.html +++ b/reference/GT.fmt_image.html @@ -275,7 +275,7 @@

    Parameters

    Examples

    Using a small portion of [metro] dataset, let’s create a gt table. We will only include a few columns and rows from that table. The lines column has comma-separated listings of numbers corresponding to lines served at each station. We have a directory of SVG graphics for all of these lines in the package (the path for the image directory can be accessed via files("great_tables") / "data/metro_images", using the importlib_resources package). The filenames roughly corresponds to the data in the lines column. The fmt_image() function can be used with these inputs since the path= and file_pattern= arguments allow us to compose complete and valid file locations. What you get from this are sequences of images in the table cells, taken from the referenced graphics files on disk.

    -
    +
    from great_tables import GT
     from great_tables.data import metro
     from importlib_resources import files
    @@ -294,51 +294,51 @@ 

    Examples

    .fmt_integer(columns="passengers") )
    -
    +
    @@ -351,27 +351,27 @@

    Examples

    - + - + - + - + - + diff --git a/reference/GT.fmt_integer.html b/reference/GT.fmt_integer.html index c7963e3ae..8630d4003 100644 --- a/reference/GT.fmt_integer.html +++ b/reference/GT.fmt_integer.html @@ -314,7 +314,7 @@

    Adapt

    Examples

    For this example, we’ll use the exibble dataset as the input table. With the fmt_integer() method, we’ll format the num column as integer values having no digit separators (with the use_seps=False option).

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -322,51 +322,51 @@ 

    Examples

    .fmt_integer(columns="num", use_seps=False) )
    -
    +

    Argentine 2,079,212
    Bastille 8,069,243
    Bérault 2,106,827
    Champs-Élysées—Clemenceau 1,909,005
    Charles de Gaulle—Étoile 4,291,663
    diff --git a/reference/GT.fmt_markdown.html b/reference/GT.fmt_markdown.html index efc6615c7..cd5cd9b09 100644 --- a/reference/GT.fmt_markdown.html +++ b/reference/GT.fmt_markdown.html @@ -258,7 +258,7 @@

    Returns

    Examples:

    Let’s first create a DataFrame containing some text that is Markdown-formatted and then introduce that to GT(). We’ll then transform the md column with the fmt_markdown() method.

    -
    +
    import pandas as pd
     from great_tables import GT
     from great_tables.data import towny
    @@ -282,51 +282,51 @@ 

    Examples:

    (GT(df).fmt_markdown("md"))
    -
    +
    diff --git a/reference/GT.fmt_nanoplot.html b/reference/GT.fmt_nanoplot.html index 712bd7b3d..d4437c538 100644 --- a/reference/GT.fmt_nanoplot.html +++ b/reference/GT.fmt_nanoplot.html @@ -306,7 +306,7 @@

    Details

    Examples

    Let’s create a nanoplot from a Polars DataFrame containing multiple numbers per cell. The numbers are represented here as strings, where spaces separate the values, and the same values are present in two columns: lines and bars. We will use the fmt_nanoplot() method twice to create a line plot and a bar plot from the data in their respective columns.

    -
    +
    from great_tables import GT
     import polars as pl
     
    @@ -328,51 +328,51 @@ 

    Examples

    .fmt_nanoplot(columns="bars", plot_type="bar") )
    -
    +
    @@ -413,7 +413,7 @@

    Examples

    We can always represent the input DataFrame in a different way (with list columns) and fmt_nanoplot() will still work. While the input data is the same as in the previous example, we’ll take the opportunity here to add a reference line and a reference area to the line plot and also to the bar plot.

    -
    +
    random_numbers_df = pl.DataFrame(
         {
             "i": range(1, 5),
    @@ -440,51 +440,51 @@ 

    Examples

    reference_area=["max", "median"]) )
    -
    +
    @@ -525,7 +525,7 @@

    Examples

    Here’s an example to adjust some of the options using nanoplot_options().

    -
    +
    from great_tables import nanoplot_options
     
     (
    @@ -565,51 +565,51 @@ 

    Examples

    ) )
    -
    +
    @@ -650,7 +650,7 @@

    Examples

    Single-value bar plots and line plots can be made with fmt_nanoplot(). These run in the horizontal direction, which is ideal for tabular presentation. The key thing here is that fmt_nanoplot() expects a column of numeric values. These plots are meant for comparison across rows so the method automatically scales the horizontal bars to facilitate this type of display. The following example shows how fmt_nanoplot() can be used to create single-value bar and line plots.

    -
    +
    single_vals_df = pl.DataFrame(
         {
             "i": range(1, 6),
    @@ -664,51 +664,51 @@ 

    Examples

    .fmt_nanoplot(columns="lines", plot_type="line") )
    -
    +
    diff --git a/reference/GT.fmt_number.html b/reference/GT.fmt_number.html index 7ffea0c29..46f0f46da 100644 --- a/reference/GT.fmt_number.html +++ b/reference/GT.fmt_number.html @@ -338,7 +338,7 @@

    Adapt

    Examples

    Let’s use the exibble dataset to create a table. With the fmt_number() method, we’ll format the num column to have three decimal places (with decimals=3) and omit the use of digit separators (with use_seps=False).

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -346,51 +346,51 @@ 

    Examples

    .fmt_number(columns="num", decimals=3, use_seps=False) )
    -
    +

    diff --git a/reference/GT.fmt_percent.html b/reference/GT.fmt_percent.html index 5d8cc9db4..817f62a20 100644 --- a/reference/GT.fmt_percent.html +++ b/reference/GT.fmt_percent.html @@ -344,7 +344,7 @@

    Adapt

    Examples

    Let’s use the towny dataset as the input table. With the fmt_percent() method, we’ll format the pop_change_2016_2021_pct column to to display values as percentages (to two decimal places).

    -
    +
    from great_tables import GT
     from great_tables.data import towny
     
    @@ -355,51 +355,51 @@ 

    Examples

    (GT(towny_mini).fmt_percent("pop_change_2016_2021_pct", decimals=2))
    -
    +

    diff --git a/reference/GT.fmt_roman.html b/reference/GT.fmt_roman.html index 12a0ead0c..db708075d 100644 --- a/reference/GT.fmt_roman.html +++ b/reference/GT.fmt_roman.html @@ -270,7 +270,7 @@

    Returns

    Examples

    Let’s first create a DataFrame containing small numeric values and then introduce that to GT(). We’ll then format the roman column to appear as Roman numerals with the fmt_roman() method.

    -
    +
    import pandas as pd
     from great_tables import GT
     
    @@ -281,51 +281,51 @@ 

    Examples

    .fmt_roman(columns="roman") )
    -
    +
    diff --git a/reference/GT.fmt_scientific.html b/reference/GT.fmt_scientific.html index 02663e600..ebb9551dd 100644 --- a/reference/GT.fmt_scientific.html +++ b/reference/GT.fmt_scientific.html @@ -343,7 +343,7 @@

    Adapt

    Examples

    For this example, we’ll use the exibble dataset as the input table. With the fmt_scientific() method, we’ll format the num column to contain values in scientific formatting.

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -351,51 +351,51 @@ 

    Examples

    .fmt_scientific(columns="num") )
    -
    +

    diff --git a/reference/GT.fmt_time.html b/reference/GT.fmt_time.html index d0707d00f..6f9b50615 100644 --- a/reference/GT.fmt_time.html +++ b/reference/GT.fmt_time.html @@ -329,7 +329,7 @@

    Adapt

    Examples

    Let’s use the exibble dataset to create a simple, two-column table (keeping only the date and time columns). With the fmt_time() method, we’ll format the time column to display times formatted with the "h_m_s_p" time style.

    -
    +
    from great_tables import GT, exibble
     
     exibble_mini = exibble[["date", "time"]]
    @@ -339,51 +339,51 @@ 

    Examples

    .fmt_time(columns="time", time_style="h_m_s_p") )
    -
    +

    diff --git a/reference/GT.html b/reference/GT.html index aae1d3233..9be2a508e 100644 --- a/reference/GT.html +++ b/reference/GT.html @@ -282,56 +282,56 @@

    Returns

    Examples

    Let’s use the exibble dataset for the next few examples, we’ll learn how to make simple output tables with the GT() class. The most basic thing to do is to just use GT() with the dataset as the input.

    -
    +
    from great_tables import GT, exibble
     
     GT(exibble)
    -
    +
    @@ -446,56 +446,56 @@

    Examples

    This dataset has the row and group columns. The former contains unique values that are ideal for labeling rows, and this often happens in what is called the ‘stub’ (a reserved area that serves to label rows). With the GT() class, we can immediately place the contents of the row column into the stub column. To do this, we use the rowname_col= argument with the appropriate column name.

    -
    +
    from great_tables import GT, exibble
     
     GT(exibble, rowname_col="row")
    -
    +
    @@ -611,56 +611,56 @@

    Examples

    This sets up a table with a stub, the row labels are placed within the stub column, and a vertical dividing line has been placed on the right-hand side.

    The group column contains categorical values that are ideal for grouping rows. We can use the groupname_col= argument to place these values into row groups.

    -
    +
    from great_tables import GT, exibble
     
     GT(exibble, rowname_col="row", groupname_col="group")
    -
    +
    @@ -772,56 +772,56 @@

    Examples

    By default, values in the body of a table (and their column labels) are automatically aligned. The alignment is governed by the types of values in a column. If you’d like to disable this form of auto-alignment, the auto_align=False option can be taken.

    -
    +
    from great_tables import GT, exibble
     
     GT(exibble, rowname_col="row", auto_align=False)
    -
    +
    @@ -937,7 +937,7 @@

    Examples

    What you’ll get from that is center-alignment of all table body values and all column labels. Note that row labels in the the stub are still left-aligned; and auto_align= has no effect on alignment within the table stub.

    However which way you generate the initial table object, you can modify it with a huge variety of methods to further customize the presentation. Formatting body cells is commonly done with the family of formatting methods (e.g., fmt_number(), fmt_date(), etc.). The package supports formatting with internationalization (‘i18n’ features) and so locale-aware methods all come with a locale= argument. To avoid having to use that argument repeatedly, the GT() class has its own locale= argument. Setting a locale in that will make it available globally. Here’s an example of how that works in practice when setting locale = "fr" in GT() prior to using formatting methods:

    -
    +
    from great_tables import GT, exibble
     
     (
    @@ -947,51 +947,51 @@ 

    Examples

    .fmt_date(columns="date", date_style="day_month_year") )
    -
    +
    diff --git a/reference/GT.opt_align_table_header.html b/reference/GT.opt_align_table_header.html index a496cb2a6..ef9a64f7c 100644 --- a/reference/GT.opt_align_table_header.html +++ b/reference/GT.opt_align_table_header.html @@ -251,7 +251,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll align the header contents (consisting of the title and the subtitle) to the left with the opt_align_table_header() method.

    -
    +
    from great_tables import GT, exibble, md
     
     (
    @@ -270,51 +270,51 @@ 

    Examples

    .opt_align_table_header(align="left") )
    -
    +
    diff --git a/reference/GT.opt_all_caps.html b/reference/GT.opt_all_caps.html index 731f8067c..53fd10d47 100644 --- a/reference/GT.opt_all_caps.html +++ b/reference/GT.opt_all_caps.html @@ -257,7 +257,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll ensure that all text in the column labels, the stub, and in all row groups is transformed to all caps using the opt_all_caps() method.

    -
    +
    from great_tables import GT, exibble, md
     
     (
    @@ -276,51 +276,51 @@ 

    Examples

    .opt_all_caps() )
    -
    +
    diff --git a/reference/GT.opt_horizontal_padding.html b/reference/GT.opt_horizontal_padding.html index 2926a0722..cb3ed2898 100644 --- a/reference/GT.opt_horizontal_padding.html +++ b/reference/GT.opt_horizontal_padding.html @@ -251,7 +251,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll scale the horizontal padding of the table by a factor of 3 using the opt_horizontal_padding() method.

    -
    +
    from great_tables import GT, exibble, md
     
     gt_tbl = (
    @@ -271,51 +271,51 @@ 

    Examples

    gt_tbl.opt_horizontal_padding(scale=3)
    -
    +
    @@ -405,54 +405,54 @@

    Examples

    The overall effect of scaling the horizontal padding is that the table will appear wider or and there will added buffer space between the table elements. The overall look of the table will be more spacious and neigboring pieces of text will be less cramped.

    Let’s go the other way and scale the horizontal padding of the table by a factor of 0.5 using the opt_horizontal_padding() method.

    -
    +
    gt_tbl.opt_horizontal_padding(scale=0.5)
    -
    +
    diff --git a/reference/GT.opt_stylize.html b/reference/GT.opt_stylize.html index ffee52210..2e3e4ed92 100644 --- a/reference/GT.opt_stylize.html +++ b/reference/GT.opt_stylize.html @@ -257,7 +257,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll apply a predefined style to the table using the opt_stylize() method.

    -
    +
    from great_tables import GT, exibble, md
     
     gt_tbl = (
    @@ -278,51 +278,51 @@ 

    Examples

    gt_tbl
    -
    +
    @@ -412,54 +412,54 @@

    Examples

    The table has been stylized with the default style and color. The default style is 1 and the default color is "blue". The resulting table style is a combination of color and border settings that are applied to the table.

    We can modify the overall style and choose a different color theme by providing different values to the style= and color= arguments.

    -
    +
    gt_tbl.opt_stylize(style=2, color="green")
    -
    +
    diff --git a/reference/GT.opt_table_outline.html b/reference/GT.opt_table_outline.html index f023462c3..867d28193 100644 --- a/reference/GT.opt_table_outline.html +++ b/reference/GT.opt_table_outline.html @@ -263,7 +263,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll put an outline around the entire table using the opt_table_outline() method.

    -
    +
    from great_tables import GT, exibble, md
     
     (
    @@ -282,51 +282,51 @@ 

    Examples

    .opt_table_outline() )
    -
    +
    diff --git a/reference/GT.opt_vertical_padding.html b/reference/GT.opt_vertical_padding.html index 403fc3832..2a414b119 100644 --- a/reference/GT.opt_vertical_padding.html +++ b/reference/GT.opt_vertical_padding.html @@ -251,7 +251,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll scale the vertical padding of the table by a factor of 3 using the opt_vertical_padding() method.

    -
    +
    from great_tables import GT, exibble, md
     
     gt_tbl = (
    @@ -271,51 +271,51 @@ 

    Examples

    gt_tbl.opt_vertical_padding(scale=3)
    -
    +
    @@ -405,54 +405,54 @@

    Examples

    Now that’s a tall table! The overall effect of scaling the vertical padding is that the table will appear taller and there will be more buffer space between the table elements. A value of 3 is pretty extreme and is likely to be too much in most cases, so, feel free to experiment with different values when looking to increase the vertical padding.

    Let’s go the other way (using a value less than 1) and try to condense the content vertically with a scale factor of 0.5. This will reduce the top and bottom padding globally and make the table appear more compact.

    -
    +
    gt_tbl.opt_vertical_padding(scale=0.5)
    -
    +
    diff --git a/reference/GT.sub_missing.html b/reference/GT.sub_missing.html index 48686382d..057e1abb0 100644 --- a/reference/GT.sub_missing.html +++ b/reference/GT.sub_missing.html @@ -257,7 +257,7 @@

    Returns

    Examples

    Using a subset of the exibble dataset, let’s create a new table. The missing values in two selections of columns will be given different variations of replacement text (across two separate calls of sub_missing()).

    -
    +
    from great_tables import GT, md, html, exibble
     import polars as pl
     import polars.selectors as cs
    @@ -276,51 +276,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.sub_zero.html b/reference/GT.sub_zero.html index d1d816230..12d02af6d 100644 --- a/reference/GT.sub_zero.html +++ b/reference/GT.sub_zero.html @@ -257,7 +257,7 @@

    Returns

    Examples

    Let’s generate a simple table that contains an assortment of values that could potentially undergo some substitution via the sub_zero() method (i.e., there are two 0 values). The ordering of the fmt_scientific() and sub_zero() calls in the example below doesn’t affect the final result since any sub_*() method won’t interfere with the formatting of the table.

    -
    +
    from great_tables import GT
     import polars as pl
     
    @@ -270,51 +270,51 @@ 

    Examples

    GT(single_vals_df).fmt_scientific(columns="numbers").sub_zero()
    -
    +
    diff --git a/reference/GT.tab_header.html b/reference/GT.tab_header.html index 11ddfa23f..bbd723ace 100644 --- a/reference/GT.tab_header.html +++ b/reference/GT.tab_header.html @@ -257,7 +257,7 @@

    Returns

    Examples

    Let’s use a small portion of the gtcars dataset to create a table. A header part can be added to the table with the tab_header() method. We’ll add a title and the optional subtitle as well. With the md() helper function, we can make sure the Markdown formatting is interpreted and transformed.

    -
    +
    from great_tables import GT, md
     from great_tables.data import gtcars
     
    @@ -271,51 +271,51 @@ 

    Examples

    ) )
    -
    +
    @@ -368,7 +368,7 @@

    Examples

    We can alternatively use the html() helper function to retain HTML elements in the text.

    -
    +
    from great_tables import GT, md, html
     from great_tables.data import gtcars
     
    @@ -382,51 +382,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.tab_options.html b/reference/GT.tab_options.html index e20067d8f..92ac7a32e 100644 --- a/reference/GT.tab_options.html +++ b/reference/GT.tab_options.html @@ -941,7 +941,7 @@

    Returns

    Examples

    Using select columns from the exibble dataset, let’s create a new table with a number of table components added. We can use this object going forward to demonstrate some of the features available in the tab_options() method.

    -
    +
    from great_tables import GT, exibble, md
     
     gt_tbl = (
    @@ -961,51 +961,51 @@ 

    Examples

    gt_tbl
    -
    +
    @@ -1094,54 +1094,54 @@

    Examples

    We can modify the table width to be set as "100%“. In effect, this spans the table to entirely fill the content width area. This is done with the table_width option.

    -
    +
    gt_tbl.tab_options(table_width="100%")
    -
    +
    @@ -1230,54 +1230,54 @@

    Examples

    With the table_background_color option, we can modify the table’s background color. Here, we want that to be "lightcyan".

    -
    +
    gt_tbl.tab_options(table_background_color="lightcyan")
    -
    +
    @@ -1366,54 +1366,54 @@

    Examples

    The data rows of a table typically take up the most physical space but we have some control over the extent of that. With the data_row_padding option, it’s possible to modify the top and bottom padding of data rows. We’ll do just that in the following example, reducing the padding to a value of "3px".

    -
    +
    gt_tbl.tab_options(data_row_padding="3px")
    -
    +
    @@ -1502,54 +1502,54 @@

    Examples

    The size of the title and the subtitle text in the header of the table can be altered with the heading_title_font_size and heading_subtitle_font_size options. Here, we’ll use the "small" and "x-small" keyword values.

    -
    +
    gt_tbl.tab_options(heading_title_font_size="small", heading_subtitle_font_size="x-small")
    -
    +
    diff --git a/reference/GT.tab_source_note.html b/reference/GT.tab_source_note.html index 7fd82e35c..b1fe8c8d8 100644 --- a/reference/GT.tab_source_note.html +++ b/reference/GT.tab_source_note.html @@ -245,7 +245,7 @@

    Returns

    Examples

    With three columns from the gtcars dataset, let’s create a new table. We can use the tab_source_note() method to add a source note to the table footer. Here we are citing the data source but this method can be used for any text you’d prefer to display in the footer component of the table.

    -
    +
    from great_tables import GT
     from great_tables.data import gtcars
     
    @@ -256,51 +256,51 @@ 

    Examples

    .tab_source_note(source_note="From edmunds.com") )
    -
    +
    diff --git a/reference/GT.tab_spanner.html b/reference/GT.tab_spanner.html index f126e7966..8d2aad70e 100644 --- a/reference/GT.tab_spanner.html +++ b/reference/GT.tab_spanner.html @@ -282,7 +282,7 @@

    Returns

    Examples

    Let’s create a table using a small portion of the gtcars dataset. Over several columns (hp, hp_rpm, trq, trq_rpm, mpg_c, mpg_h) we’ll use tab_spanner() to add a spanner with the label "performance". This effectively groups together several columns related to car performance under a unifying label.

    -
    +
    from great_tables import GT
     from great_tables.data import gtcars
     
    @@ -297,51 +297,51 @@ 

    Examples

    ) )
    -
    +
    @@ -461,7 +461,7 @@

    Examples

    We can also use Markdown formatting for the spanner label. In this example, we’ll use gt.md("*Performance*") to make the label italicized.

    -
    +
    from great_tables import GT, md
     from great_tables.data import gtcars
     
    @@ -476,51 +476,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/GT.tab_stubhead.html b/reference/GT.tab_stubhead.html index 37c0b2668..76d4363ab 100644 --- a/reference/GT.tab_stubhead.html +++ b/reference/GT.tab_stubhead.html @@ -245,7 +245,7 @@

    Returns

    Examples

    Using a small subset of the gtcars dataset, we can create a table with row labels. Since we have row labels in the stub (via use of rowname_col="model" in the GT() call) we have a stubhead, so, let’s add a stubhead label ("car") with the tab_stubhead() method to describe what’s in the stub.

    -
    +
    from great_tables import GT
     from great_tables.data import gtcars
     
    @@ -256,51 +256,51 @@ 

    Examples

    .tab_stubhead(label="car") )
    -
    +
    @@ -352,7 +352,7 @@

    Examples

    We can also use Markdown formatting for the stubhead label. In this example, we’ll use md("*Car*") to make the label italicized.

    -
    +
    from great_tables import GT, md
     from great_tables.data import gtcars
     
    @@ -361,51 +361,51 @@ 

    Examples

    .tab_stubhead(label=md("*Car*")) )
    -
    +
    diff --git a/reference/GT.tab_style.html b/reference/GT.tab_style.html index 5bc0173ae..f2e463211 100644 --- a/reference/GT.tab_style.html +++ b/reference/GT.tab_style.html @@ -265,7 +265,7 @@

    Returns

    Examples

    Let’s use a small subset of the exibble dataset to demonstrate how to use tab_style() to target specific cells and apply styles to them. We’ll start by creating the exibble_sm table (a subset of the exibble table) and then use tab_style() to apply a light cyan background color to the cells in the num column for the first two rows of the table. We’ll then apply a larger font size to the cells in the fctr column for the last four rows of the table.

    -
    +
    from great_tables import GT, style, loc, exibble
     
     exibble_sm = exibble[["num", "fctr", "row", "group"]]
    @@ -282,51 +282,51 @@ 

    Examples

    ) )
    -
    +
    @@ -393,7 +393,7 @@

    Examples

    Let’s use exibble once again to create a simple, two-column output table (keeping only the num and currency columns). With the tab_style() method (called thrice), we’ll add style to the values already formatted by fmt_number() and fmt_currency(). In the style argument of the first two tab_style() call, we can define multiple types of styling with the style.fill() and style.text() classes (enclosing these in a list). The cells to be targeted for styling require the use of loc.body(), which is used here with different columns being targeted. For the final tab_style() call, we demonstrate the use of style.borders() class as the style argument, which is employed in conjunction with loc.body() to locate the row to be styled.

    -
    +
    from great_tables import GT, style, loc, exibble
     
     (
    @@ -420,51 +420,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/from_column.html b/reference/from_column.html index 4f5eb2145..e4404d6e9 100644 --- a/reference/from_column.html +++ b/reference/from_column.html @@ -203,7 +203,7 @@

    from_column

    Specify that a style value should be fetched from a column in the data.

    Examples

    -
    +
    import pandas as pd
     from great_tables import GT, exibble, from_column, loc, style
     
    @@ -217,51 +217,51 @@ 

    Examples

    ) )
    -
    +
    @@ -289,7 +289,7 @@

    Examples

    If you are using polars, you can just pass polars expressions in directly:

    -
    +
    import polars as pl
     from great_tables import GT, exibble, from_column, loc, style
     
    @@ -303,51 +303,51 @@ 

    Examples

    ) )
    -
    +
    diff --git a/reference/system_fonts.html b/reference/system_fonts.html index c63a533e6..906eb4951 100644 --- a/reference/system_fonts.html +++ b/reference/system_fonts.html @@ -351,7 +351,7 @@

    Handwritten (

    Examples

    Using select columns from the exibble dataset, let’s create a table with a number of components added. Following that, we’ll set a font for the entire table using the tab_options() method with the table_font_names parameter. Instead of passing a list of font names, we’ll use the system_fonts() helper function to get a font stack. In this case, we’ll use the "industrial" font stack.

    -
    +
    from great_tables import GT, exibble, md, system_fonts
     
     (
    @@ -371,51 +371,51 @@ 

    Examples

    .tab_options(table_font_names=system_fonts("industrial")) )
    -
    +

    diff --git a/search.json b/search.json index 594605f1a..5a617959a 100644 --- a/search.json +++ b/search.json @@ -2018,7 +2018,7 @@ "href": "reference/GT.as_raw_html.html#examples", "title": "GT.as_raw_html", "section": "Examples:", - "text": "Examples:\nLet’s use the row column of exibble dataset to create a table. With the as_raw_html() method, we’re able to output the HTML content.\n\nfrom great_tables import GT, exibble\n\nGT(exibble[[\"row\"]]).as_raw_html()\n\n'<div id=\"qpvkwvtyfn\" style=\"padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;\">\\n<style>\\n#qpvkwvtyfn table {\\n font-family: -apple-system, BlinkMacSystemFont, \\'Segoe UI\\', Roboto, Oxygen, Ubuntu, Cantarell, \\'Helvetica Neue\\', \\'Fira Sans\\', \\'Droid Sans\\', Arial, sans-serif;\\n -webkit-font-smoothing: antialiased;\\n -moz-osx-font-smoothing: grayscale;\\n }\\n\\n#qpvkwvtyfn thead, tbody, tfoot, tr, td, th { border-style: none; }\\n tr { background-color: transparent; }\\n#qpvkwvtyfn p { margin: 0; padding: 0; }\\n #qpvkwvtyfn .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }\\n #qpvkwvtyfn .gt_caption { padding-top: 4px; padding-bottom: 4px; }\\n #qpvkwvtyfn .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }\\n #qpvkwvtyfn .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }\\n #qpvkwvtyfn .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\\n #qpvkwvtyfn .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }\\n #qpvkwvtyfn .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\\n #qpvkwvtyfn .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }\\n #qpvkwvtyfn .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }\\n #qpvkwvtyfn .gt_column_spanner_outer:first-child { padding-left: 0; }\\n #qpvkwvtyfn .gt_column_spanner_outer:last-child { padding-right: 0; }\\n #qpvkwvtyfn .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }\\n #qpvkwvtyfn .gt_spanner_row { border-bottom-style: hidden; }\\n #qpvkwvtyfn .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }\\n #qpvkwvtyfn .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }\\n #qpvkwvtyfn .gt_from_md> :first-child { margin-top: 0; }\\n #qpvkwvtyfn .gt_from_md> :last-child { margin-bottom: 0; }\\n #qpvkwvtyfn .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }\\n #qpvkwvtyfn .gt_stub { 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; }\\n #qpvkwvtyfn .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; }\\n #qpvkwvtyfn .gt_row_group_first td { border-top-width: 2px; }\\n #qpvkwvtyfn .gt_row_group_first th { border-top-width: 2px; }\\n #qpvkwvtyfn .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; }\\n #qpvkwvtyfn .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; }\\n #qpvkwvtyfn .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }\\n #qpvkwvtyfn .gt_left { text-align: left; }\\n #qpvkwvtyfn .gt_center { text-align: center; }\\n #qpvkwvtyfn .gt_right { text-align: right; font-variant-numeric: tabular-nums; }\\n #qpvkwvtyfn .gt_font_normal { font-weight: normal; }\\n #qpvkwvtyfn .gt_font_bold { font-weight: bold; }\\n #qpvkwvtyfn .gt_font_italic { font-style: italic; }\\n #qpvkwvtyfn .gt_super { font-size: 65%; }\\n #qpvkwvtyfn .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }\\n #qpvkwvtyfn .gt_asterisk { font-size: 100%; vertical-align: 0; }\\n \\n</style>\\n<table class=\"gt_table\" data-quarto-disable-processing=\"false\" data-quarto-bootstrap=\"false\">\\n\\n<tr class=\"gt_col_headings\">\\n <th class=\"gt_col_heading gt_columns_bottom_border gt_left\" rowspan=\"1\" colspan=\"1\" scope=\"col\" id=\"row\">row</th>\\n</tr>\\n<tbody class=\"gt_table_body\">\\n <tr>\\n <td class=\"gt_row gt_left\">row_1</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_2</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_3</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_4</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_5</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_6</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_7</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_8</td>\\n </tr>\\n</tbody>\\n\\n\\n</table>\\n\\n</div>\\n '" + "text": "Examples:\nLet’s use the row column of exibble dataset to create a table. With the as_raw_html() method, we’re able to output the HTML content.\n\nfrom great_tables import GT, exibble\n\nGT(exibble[[\"row\"]]).as_raw_html()\n\n'<div id=\"mrmlkjyjkb\" style=\"padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;\">\\n<style>\\n#mrmlkjyjkb table {\\n font-family: -apple-system, BlinkMacSystemFont, \\'Segoe UI\\', Roboto, Oxygen, Ubuntu, Cantarell, \\'Helvetica Neue\\', \\'Fira Sans\\', \\'Droid Sans\\', Arial, sans-serif;\\n -webkit-font-smoothing: antialiased;\\n -moz-osx-font-smoothing: grayscale;\\n }\\n\\n#mrmlkjyjkb thead, tbody, tfoot, tr, td, th { border-style: none; }\\n tr { background-color: transparent; }\\n#mrmlkjyjkb p { margin: 0; padding: 0; }\\n #mrmlkjyjkb .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }\\n #mrmlkjyjkb .gt_caption { padding-top: 4px; padding-bottom: 4px; }\\n #mrmlkjyjkb .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }\\n #mrmlkjyjkb .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }\\n #mrmlkjyjkb .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\\n #mrmlkjyjkb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }\\n #mrmlkjyjkb .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\\n #mrmlkjyjkb .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }\\n #mrmlkjyjkb .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }\\n #mrmlkjyjkb .gt_column_spanner_outer:first-child { padding-left: 0; }\\n #mrmlkjyjkb .gt_column_spanner_outer:last-child { padding-right: 0; }\\n #mrmlkjyjkb .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }\\n #mrmlkjyjkb .gt_spanner_row { border-bottom-style: hidden; }\\n #mrmlkjyjkb .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }\\n #mrmlkjyjkb .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }\\n #mrmlkjyjkb .gt_from_md> :first-child { margin-top: 0; }\\n #mrmlkjyjkb .gt_from_md> :last-child { margin-bottom: 0; }\\n #mrmlkjyjkb .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }\\n #mrmlkjyjkb .gt_stub { 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; }\\n #mrmlkjyjkb .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; }\\n #mrmlkjyjkb .gt_row_group_first td { border-top-width: 2px; }\\n #mrmlkjyjkb .gt_row_group_first th { border-top-width: 2px; }\\n #mrmlkjyjkb .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; }\\n #mrmlkjyjkb .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; }\\n #mrmlkjyjkb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }\\n #mrmlkjyjkb .gt_left { text-align: left; }\\n #mrmlkjyjkb .gt_center { text-align: center; }\\n #mrmlkjyjkb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }\\n #mrmlkjyjkb .gt_font_normal { font-weight: normal; }\\n #mrmlkjyjkb .gt_font_bold { font-weight: bold; }\\n #mrmlkjyjkb .gt_font_italic { font-style: italic; }\\n #mrmlkjyjkb .gt_super { font-size: 65%; }\\n #mrmlkjyjkb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }\\n #mrmlkjyjkb .gt_asterisk { font-size: 100%; vertical-align: 0; }\\n \\n</style>\\n<table class=\"gt_table\" data-quarto-disable-processing=\"false\" data-quarto-bootstrap=\"false\">\\n\\n<tr class=\"gt_col_headings\">\\n <th class=\"gt_col_heading gt_columns_bottom_border gt_left\" rowspan=\"1\" colspan=\"1\" scope=\"col\" id=\"row\">row</th>\\n</tr>\\n<tbody class=\"gt_table_body\">\\n <tr>\\n <td class=\"gt_row gt_left\">row_1</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_2</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_3</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_4</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_5</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_6</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_7</td>\\n </tr>\\n <tr>\\n <td class=\"gt_row gt_left\">row_8</td>\\n </tr>\\n</tbody>\\n\\n\\n</table>\\n\\n</div>\\n '" }, { "objectID": "reference/data.sza.html", @@ -2844,6 +2844,6 @@ "href": "examples/index.html", "title": "Examples", "section": "", - "text": "Show the Code\nimport polars as pl\nfrom great_tables import GT, md, html\nfrom great_tables.data import islands\n\nislands_mini = (\n pl.from_pandas(islands).sort(\"size\", descending=True)\n .head(10)\n)\n\n(\n GT(islands_mini, rowname_col=\"name\")\n .tab_header(\n title=\"Large Landmasses of the World\",\n subtitle=\"The top ten largest are presented\"\n )\n .tab_source_note(source_note=\"Source: The World Almanac and Book of Facts, 1975, page 406.\")\n .tab_source_note(\n source_note=md(\"Reference: McNeil, D. R. (1977) *Interactive Data Analysis*. Wiley.\")\n )\n .tab_stubhead(label=\"landmass\")\n .fmt_integer(columns=\"size\")\n)\n\n\n\n\n\n\n \n Large Landmasses of the World\n \n \n The top ten largest are presented\n \n\n\n landmass\n size\n\n\n \n Asia\n 16,988\n \n \n Africa\n 11,506\n \n \n North America\n 9,390\n \n \n South America\n 6,795\n \n \n Antarctica\n 5,500\n \n \n Europe\n 3,745\n \n \n Australia\n 2,968\n \n \n Greenland\n 840\n \n \n New Guinea\n 306\n \n \n Borneo\n 280\n \n\n \n \n \n Source: The World Almanac and Book of Facts, 1975, page 406.\n \n\n\n \n Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT, html\nfrom great_tables.data import airquality\n\nairquality_mini = airquality.head(10).assign(Year = 1973)\n\n(\n GT(airquality_mini)\n .tab_header(\n title=\"New York Air Quality Measurements\",\n subtitle=\"Daily measurements in New York City (May 1-10, 1973)\"\n )\n .tab_spanner(\n label=\"Time\",\n columns=[\"Year\", \"Month\", \"Day\"]\n )\n .tab_spanner(\n label=\"Measurement\",\n columns=[\"Ozone\", \"Solar_R\", \"Wind\", \"Temp\"]\n )\n .cols_move_to_start(columns=[\"Year\", \"Month\", \"Day\"])\n .cols_label(\n Ozone = html(\"Ozone,<br>ppbV\"),\n Solar_R = html(\"Solar R.,<br>cal/m<sup>2</sup>\"),\n Wind = html(\"Wind,<br>mph\"),\n Temp = html(\"Temp,<br>°F\")\n )\n)\n\n\n\n\n\n\n \n New York Air Quality Measurements\n \n \n Daily measurements in New York City (May 1-10, 1973)\n \n\n\n \n Time\n \n \n Measurement\n \n\n\n Year\n Month\n Day\n Ozone,ppbV\n Solar R.,cal/m2\n Wind,mph\n Temp,°F\n\n\n \n 1973\n 5\n 1\n 41.0\n 190.0\n 7.4\n 67\n \n \n 1973\n 5\n 2\n 36.0\n 118.0\n 8.0\n 72\n \n \n 1973\n 5\n 3\n 12.0\n 149.0\n 12.6\n 74\n \n \n 1973\n 5\n 4\n 18.0\n 313.0\n 11.5\n 62\n \n \n 1973\n 5\n 5\n \n \n 14.3\n 56\n \n \n 1973\n 5\n 6\n 28.0\n \n 14.9\n 66\n \n \n 1973\n 5\n 7\n 23.0\n 299.0\n 8.6\n 65\n \n \n 1973\n 5\n 8\n 19.0\n 99.0\n 13.8\n 59\n \n \n 1973\n 5\n 9\n 8.0\n 19.0\n 20.1\n 61\n \n \n 1973\n 5\n 10\n \n 194.0\n 8.6\n 69\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT\nfrom great_tables.data import countrypops\nimport polars as pl\nimport polars.selectors as cs\n\n# Get vectors of 2-letter country codes for each region of Oceania\noceania = {\n \"Australasia\": [\"AU\", \"NZ\"],\n \"Melanesia\": [\"NC\", \"PG\", \"SB\", \"VU\"],\n \"Micronesia\": [\"FM\", \"GU\", \"KI\", \"MH\", \"MP\", \"NR\", \"PW\"],\n \"Polynesia\": [\"PF\", \"WS\", \"TO\", \"TV\"],\n}\n\n# Create a dictionary mapping country to region (e.g. AU -> Australasia)\ncountry_to_region = {\n country: region for region, countries in oceania.items() for country in countries\n}\n\nwide_pops = (\n pl.from_pandas(countrypops)\n .filter(\n pl.col(\"country_code_2\").is_in(list(country_to_region))\n & pl.col(\"year\").is_in([2000, 2010, 2020])\n )\n .with_columns(pl.col(\"country_code_2\").replace(country_to_region).alias(\"region\"))\n .pivot(index=[\"country_name\", \"region\"], columns=\"year\", values=\"population\")\n .sort(\"2020\", descending=True)\n)\n\n(\n GT(wide_pops, rowname_col=\"country_name\", groupname_col=\"region\")\n .tab_header(title=\"Populations of Oceania's Countries in 2000, 2010, and 2020\")\n .tab_spanner(label=\"Total Population\", columns=cs.all())\n .fmt_integer()\n)\n\n\n\n\n\n\n \n Populations of Oceania's Countries in 2000, 2010, and 2020\n \n\n\n \n \n Total Population\n \n\n\n 2000\n 2010\n 2020\n\n\n \n Australasia\n \n \n Australia\n 19,028,802\n 22,031,750\n 25,655,289\n \n \n New Zealand\n 3,857,700\n 4,350,700\n 5,090,200\n \n \n Melanesia\n \n \n Papua New Guinea\n 5,508,297\n 7,583,269\n 9,749,640\n \n \n Solomon Islands\n 429,978\n 540,394\n 691,191\n \n \n Vanuatu\n 192,074\n 245,453\n 311,685\n \n \n New Caledonia\n 213,230\n 249,750\n 272,460\n \n \n Polynesia\n \n \n French Polynesia\n 250,927\n 283,788\n 301,920\n \n \n Samoa\n 184,008\n 194,672\n 214,929\n \n \n Tonga\n 102,603\n 107,383\n 105,254\n \n \n Tuvalu\n 9,638\n 10,550\n 11,069\n \n \n Micronesia\n \n \n Guam\n 160,188\n 164,905\n 169,231\n \n \n Kiribati\n 88,826\n 107,995\n 126,463\n \n \n Micronesia (Federated States)\n 111,709\n 107,588\n 112,106\n \n \n Northern Mariana Islands\n 80,338\n 54,087\n 49,587\n \n \n Marshall Islands\n 54,224\n 53,416\n 43,413\n \n \n Palau\n 19,726\n 18,540\n 17,972\n \n \n Nauru\n 10,377\n 10,241\n 12,315\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT, html\nfrom great_tables.data import towny\n\ntowny_mini = (\n towny[[\"name\", \"website\", \"density_2021\", \"land_area_km2\", \"latitude\", \"longitude\"]]\n .sort_values(\"density_2021\", ascending=False)\n .head(10)\n)\n\ntowny_mini[\"url_name\"] = [\"[\"] + towny_mini[\"name\"] + [\"]\"] + [\"(\"] + towny_mini[\"website\"] + [\")\"]\n\ntowny_mini[\"location\"] = (\n [\"[map](http://maps.google.com/?ie=UTF8&hq=&ll=\"]\n + towny_mini[\"latitude\"].astype(str)\n + [\",\"]\n + towny_mini[\"longitude\"].astype(str)\n + [\"&z=13)\"]\n)\n\n(\n GT(\n towny_mini[[\"url_name\", \"location\", \"land_area_km2\", \"density_2021\"]],\n rowname_col=\"url_name\",\n )\n .tab_header(\n title=\"The Municipalities of Ontario\",\n subtitle=\"The top 10 highest population density in 2021\",\n )\n .tab_stubhead(label=\"Municipality\")\n .fmt_markdown(columns=[\"url_name\", \"location\"])\n .fmt_number(columns=[\"land_area_km2\", \"density_2021\"], decimals=1)\n .cols_label(\n land_area_km2=html(\"land area, <br>km<sup>2</sup>\"),\n density_2021=html(\"density, <br>people/km<sup>2</sup>\"),\n )\n)\n\n\n\n\n\n\n \n The Municipalities of Ontario\n \n \n The top 10 highest population density in 2021\n \n\n\n Municipality\n location\n land area, km2\n density, people/km2\n\n\n \n Toronto\n map\n 631.1\n 4,427.8\n \n \n Brampton\n map\n 265.9\n 2,469.0\n \n \n Mississauga\n map\n 292.7\n 2,452.6\n \n \n Newmarket\n map\n 38.5\n 2,284.2\n \n \n Richmond Hill\n map\n 100.8\n 2,004.4\n \n \n Orangeville\n map\n 15.2\n 1,989.9\n \n \n Ajax\n map\n 66.6\n 1,900.8\n \n \n Waterloo\n map\n 64.1\n 1,895.7\n \n \n Kitchener\n map\n 136.8\n 1,877.7\n \n \n Guelph\n map\n 87.4\n 1,644.1\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT, html\nfrom great_tables.data import sza\nimport polars as pl\nimport polars.selectors as cs\n\nsza_pivot = (\n pl.from_pandas(sza)\n .filter((pl.col(\"latitude\") == \"20\") & (pl.col(\"tst\") <= \"1200\"))\n .select(pl.col(\"*\").exclude(\"latitude\"))\n .drop_nulls()\n .pivot(values=\"sza\", index=\"month\", columns=\"tst\", sort_columns=True)\n)\n\n(\n GT(sza_pivot, rowname_col=\"month\")\n .data_color(\n domain=[90, 0],\n palette=[\"rebeccapurple\", \"white\", \"orange\"],\n na_color=\"white\",\n )\n .tab_header(\n title=\"Solar Zenith Angles from 05:30 to 12:00\",\n subtitle=html(\"Average monthly values at latitude of 20°N.\"),\n )\n .sub_missing(missing_text=\"\")\n)\n\n\n\n\n\n\n \n Solar Zenith Angles from 05:30 to 12:00\n \n \n Average monthly values at latitude of 20°N.\n \n\n\n \n 0530\n 0600\n 0630\n 0700\n 0730\n 0800\n 0830\n 0900\n 0930\n 1000\n 1030\n 1100\n 1130\n 1200\n\n\n \n jan\n \n \n \n 84.9\n 78.7\n 72.7\n 66.1\n 61.5\n 56.5\n 52.1\n 48.3\n 45.5\n 43.6\n 43.0\n \n \n feb\n \n \n 88.9\n 82.5\n 75.8\n 69.6\n 63.3\n 57.7\n 52.2\n 47.4\n 43.1\n 40.0\n 37.8\n 37.2\n \n \n mar\n \n \n 85.7\n 78.8\n 72.0\n 65.2\n 58.6\n 52.3\n 46.2\n 40.5\n 35.5\n 31.4\n 28.6\n 27.7\n \n \n apr\n \n 88.5\n 81.5\n 74.4\n 67.4\n 60.3\n 53.4\n 46.5\n 39.7\n 33.2\n 26.9\n 21.3\n 17.2\n 15.5\n \n \n may\n \n 85.0\n 78.2\n 71.2\n 64.3\n 57.2\n 50.2\n 43.2\n 36.1\n 29.1\n 26.1\n 15.2\n 8.8\n 5.0\n \n \n jun\n 89.2\n 82.7\n 76.0\n 69.3\n 62.5\n 55.7\n 48.8\n 41.9\n 35.0\n 28.1\n 21.1\n 14.2\n 7.3\n 2.0\n \n \n jul\n 88.8\n 82.3\n 75.7\n 69.1\n 62.3\n 55.5\n 48.7\n 41.8\n 35.0\n 28.1\n 21.2\n 14.3\n 7.7\n 3.1\n \n \n aug\n \n 83.8\n 77.1\n 70.2\n 63.3\n 56.4\n 49.4\n 42.4\n 35.4\n 28.3\n 21.3\n 14.3\n 7.3\n 1.9\n \n \n sep\n \n 87.2\n 80.2\n 73.2\n 66.1\n 59.1\n 52.1\n 45.1\n 38.1\n 31.3\n 24.7\n 18.6\n 13.7\n 11.6\n \n \n oct\n \n \n 84.1\n 77.1\n 70.2\n 63.3\n 56.5\n 49.9\n 43.5\n 37.5\n 32.0\n 27.4\n 24.3\n 23.1\n \n \n nov\n \n \n 87.8\n 81.3\n 74.5\n 68.3\n 61.8\n 56.0\n 50.2\n 45.3\n 40.7\n 37.4\n 35.1\n 34.4\n \n \n dec\n \n \n \n 84.3\n 78.0\n 71.8\n 66.1\n 60.5\n 55.6\n 50.9\n 47.2\n 44.2\n 42.4\n 41.8\n \n\n\n\n\n\n\n \n\n\n\n\nView notebook ⬀\n\n\n\n\n\n\n \n Highest Paid Athletes in 2023\n \n\n \n Name\n icon\n Sport\n \n Earnings\n \n\n\n Total $M\n Off field $M\n Off field %\n\n\n\n 1\n Cristiano Ronaldo\n \n Soccer\n 136.0\n 90.0\n \n\n\n 2\n Lionel Messi\n \n Soccer\n 130.0\n 65.0\n \n\n\n 3\n Kylian Mbappé\n \n Soccer\n 120.0\n 20.0\n \n\n\n 4\n LeBron James\n \n Basketball\n 119.5\n 75.0\n \n\n\n 5\n Canelo Alvarez\n \n Boxing\n 110.0\n 10.0\n \n\n\n 6\n Dustin Johnson\n \n Golf\n 107.0\n 5.0\n \n\n\n 7\n Phil Mickelson\n \n Golf\n 106.0\n 2.0\n \n\n\n 8\n Stephen Curry\n \n Basketball\n 100.4\n 52.0\n \n\n\n 9\n Roger Federer\n \n Tennis\n 95.1\n 95.0\n \n\n\n \n \n \n Original table: @LisaHornung_ | Sports icons: Firza Alamsyah | Data: Forbes\n \n\n\n\n\n\n\n \n\n\n\n\n\nView source ⬀     Blog post (R code) ⬀\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n \n 2023 Mean Carbon Intensity (gCO2eq/kWh) and Power Consumption Breakdown (%)\n \n\n\n Zone\n CO2 Intensity\n Hydro\n Nuclear\n Wind\n Solar\n Geothermal\n Biomass\n Gas\n Coal\n Oil\n Unknown\n Hydro Discharge\n Battery Discharge\n\n\n \n Sweden\n 26\n 39.1%\n 26.8%\n 27.7%\n 0.1%\n 0.0%\n 0.4%\n 0.4%\n 0.8%\n 0.0%\n 4.6%\n 0.1%\n 0.0%\n \n \n Iceland\n 28\n 69.4%\n 0.0%\n 0.0%\n 0.0%\n 30.6%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n Quebec\n 35\n 90.1%\n 2.1%\n 4.4%\n 0.0%\n 0.0%\n 1.9%\n 1.4%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n France\n 46\n 12.3%\n 65.4%\n 10.3%\n 1.8%\n 0.0%\n 1.0%\n 7.1%\n 0.3%\n 0.3%\n 0.1%\n 1.4%\n 0.0%\n \n \n Ontario\n 104\n 23.3%\n 49.4%\n 8.7%\n 0.1%\n 0.0%\n 0.2%\n 18.1%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n New Zealand\n 106\n 60.5%\n 0.0%\n 7.7%\n 0.1%\n 19.0%\n 0.0%\n 6.8%\n 3.7%\n 0.0%\n 2.2%\n 0.0%\n 0.0%\n \n \n Finland\n 107\n 20.2%\n 36.5%\n 24.1%\n 0.1%\n 0.0%\n 6.2%\n 3.0%\n 8.1%\n 0.0%\n 1.8%\n 0.0%\n 0.0%\n \n \n South Australia\n 132\n 0.7%\n 0.0%\n 42.6%\n 33.7%\n 0.0%\n 0.0%\n 13.3%\n 9.0%\n 0.0%\n 0.0%\n 0.0%\n 0.7%\n \n \n Spain\n 132\n 17.1%\n 24.2%\n 25.1%\n 8.0%\n 0.0%\n 2.0%\n 18.8%\n 1.3%\n 0.2%\n 0.3%\n 3.0%\n 0.0%\n \n \n Belgium\n 147\n 1.3%\n 39.6%\n 25.2%\n 3.6%\n 0.0%\n 2.8%\n 19.4%\n 1.7%\n 0.1%\n 4.9%\n 1.2%\n 0.0%\n \n \n Tasmania\n 162\n 49.0%\n 0.0%\n 22.6%\n 10.8%\n 0.0%\n 0.0%\n 1.5%\n 16.1%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n East Denmark\n 184\n 6.4%\n 5.5%\n 48.4%\n 1.3%\n 0.0%\n 16.8%\n 7.7%\n 10.8%\n 1.4%\n 1.4%\n 0.4%\n 0.0%\n \n \n West Denmark\n 188\n 8.8%\n 2.2%\n 56.3%\n 1.6%\n 0.0%\n 7.6%\n 8.5%\n 13.0%\n 0.9%\n 0.4%\n 0.6%\n 0.0%\n \n \n Great Britain\n 214\n 3.8%\n 12.4%\n 35.9%\n 2.7%\n 0.0%\n 6.2%\n 35.1%\n 2.0%\n 0.0%\n 1.0%\n 1.0%\n 0.0%\n \n \n Netherlands\n 218\n 1.1%\n 3.9%\n 46.7%\n 10.8%\n 0.0%\n 4.6%\n 22.4%\n 8.6%\n 0.8%\n 1.1%\n 0.2%\n 0.0%\n \n \n New York ISO\n 275\n 23.7%\n 22.8%\n 4.9%\n 0.0%\n 0.0%\n 0.1%\n 46.9%\n 0.0%\n 0.0%\n 1.6%\n 0.0%\n 0.0%\n \n \n Italy (North)\n 307\n 22.7%\n 14.5%\n 3.9%\n 2.9%\n 0.2%\n 3.1%\n 38.4%\n 1.5%\n 0.2%\n 9.3%\n 3.3%\n 0.0%\n \n \n California\n 328\n 8.4%\n 12.7%\n 7.9%\n 12.0%\n 3.0%\n 1.8%\n 48.5%\n 2.1%\n 0.0%\n 1.2%\n 0.0%\n 2.6%\n \n \n Germany\n 389\n 4.4%\n 2.8%\n 39.7%\n 3.3%\n 0.0%\n 8.7%\n 14.4%\n 23.3%\n 0.6%\n 0.6%\n 2.1%\n 0.0%\n \n \n Ireland\n 389\n 3.7%\n 0.8%\n 38.5%\n 0.2%\n 0.0%\n 2.5%\n 42.4%\n 9.7%\n 2.0%\n 0.1%\n 0.1%\n 0.0%\n \n \n Western Australia\n 417\n 0.0%\n 0.0%\n 14.1%\n 33.8%\n 0.0%\n 0.3%\n 24.2%\n 27.1%\n 0.3%\n 0.0%\n 0.0%\n 0.3%\n \n \n Texas\n 432\n 0.0%\n 9.1%\n 22.3%\n 6.0%\n 0.0%\n 0.0%\n 46.1%\n 16.1%\n 0.0%\n 0.4%\n 0.0%\n 0.0%\n \n \n Alberta\n 447\n 1.9%\n 0.0%\n 12.4%\n 1.1%\n 0.0%\n 2.5%\n 70.7%\n 7.2%\n 0.0%\n 4.1%\n 0.0%\n 0.0%\n \n \n Victoria\n 508\n 3.9%\n 0.0%\n 17.5%\n 19.0%\n 0.0%\n 0.0%\n 0.3%\n 59.1%\n 0.0%\n 0.0%\n 0.0%\n 0.2%\n \n \n New South Wales\n 578\n 3.2%\n 0.0%\n 9.5%\n 23.7%\n 0.0%\n 0.2%\n 0.7%\n 62.6%\n 0.0%\n 0.0%\n 0.0%\n 0.1%\n \n \n Queensland\n 662\n 1.9%\n 0.0%\n 3.8%\n 21.1%\n 0.0%\n 0.0%\n 7.2%\n 65.7%\n 0.2%\n 0.0%\n 0.0%\n 0.1%\n \n \n South Africa\n 685\n 2.2%\n 4.3%\n 5.8%\n 3.8%\n 0.0%\n 0.0%\n 0.0%\n 79.9%\n 2.0%\n 0.1%\n 2.0%\n 0.0%\n \n \n India (North)\n 693\n 9.3%\n 2.2%\n 0.1%\n 10.6%\n 0.0%\n 0.0%\n 1.8%\n 75.2%\n 0.0%\n 0.9%\n 0.0%\n 0.0%\n \n\n \n \n \n Source: api.electricitymap.org | Methodology: https://www.electricitymaps.com/methodology. Some emissions factors are based on IPCC 2014 defaults, while some are based on more accurate regional factors. All zones are publicly available on the Carbon intensity and emission factors tab via Google docs link" + "text": "Show the Code\nimport polars as pl\nfrom great_tables import GT, md, html\nfrom great_tables.data import islands\n\nislands_mini = (\n pl.from_pandas(islands).sort(\"size\", descending=True)\n .head(10)\n)\n\n(\n GT(islands_mini, rowname_col=\"name\")\n .tab_header(\n title=\"Large Landmasses of the World\",\n subtitle=\"The top ten largest are presented\"\n )\n .tab_source_note(source_note=\"Source: The World Almanac and Book of Facts, 1975, page 406.\")\n .tab_source_note(\n source_note=md(\"Reference: McNeil, D. R. (1977) *Interactive Data Analysis*. Wiley.\")\n )\n .tab_stubhead(label=\"landmass\")\n .fmt_integer(columns=\"size\")\n)\n\n\n\n\n\n\n \n Large Landmasses of the World\n \n \n The top ten largest are presented\n \n\n\n landmass\n size\n\n\n \n Asia\n 16,988\n \n \n Africa\n 11,506\n \n \n North America\n 9,390\n \n \n South America\n 6,795\n \n \n Antarctica\n 5,500\n \n \n Europe\n 3,745\n \n \n Australia\n 2,968\n \n \n Greenland\n 840\n \n \n New Guinea\n 306\n \n \n Borneo\n 280\n \n\n \n \n \n Source: The World Almanac and Book of Facts, 1975, page 406.\n \n\n\n \n Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT, html\nfrom great_tables.data import airquality\n\nairquality_mini = airquality.head(10).assign(Year = 1973)\n\n(\n GT(airquality_mini)\n .tab_header(\n title=\"New York Air Quality Measurements\",\n subtitle=\"Daily measurements in New York City (May 1-10, 1973)\"\n )\n .tab_spanner(\n label=\"Time\",\n columns=[\"Year\", \"Month\", \"Day\"]\n )\n .tab_spanner(\n label=\"Measurement\",\n columns=[\"Ozone\", \"Solar_R\", \"Wind\", \"Temp\"]\n )\n .cols_move_to_start(columns=[\"Year\", \"Month\", \"Day\"])\n .cols_label(\n Ozone = html(\"Ozone,<br>ppbV\"),\n Solar_R = html(\"Solar R.,<br>cal/m<sup>2</sup>\"),\n Wind = html(\"Wind,<br>mph\"),\n Temp = html(\"Temp,<br>°F\")\n )\n)\n\n\n\n\n\n\n \n New York Air Quality Measurements\n \n \n Daily measurements in New York City (May 1-10, 1973)\n \n\n\n \n Time\n \n \n Measurement\n \n\n\n Year\n Month\n Day\n Ozone,ppbV\n Solar R.,cal/m2\n Wind,mph\n Temp,°F\n\n\n \n 1973\n 5\n 1\n 41.0\n 190.0\n 7.4\n 67\n \n \n 1973\n 5\n 2\n 36.0\n 118.0\n 8.0\n 72\n \n \n 1973\n 5\n 3\n 12.0\n 149.0\n 12.6\n 74\n \n \n 1973\n 5\n 4\n 18.0\n 313.0\n 11.5\n 62\n \n \n 1973\n 5\n 5\n \n \n 14.3\n 56\n \n \n 1973\n 5\n 6\n 28.0\n \n 14.9\n 66\n \n \n 1973\n 5\n 7\n 23.0\n 299.0\n 8.6\n 65\n \n \n 1973\n 5\n 8\n 19.0\n 99.0\n 13.8\n 59\n \n \n 1973\n 5\n 9\n 8.0\n 19.0\n 20.1\n 61\n \n \n 1973\n 5\n 10\n \n 194.0\n 8.6\n 69\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT\nfrom great_tables.data import countrypops\nimport polars as pl\nimport polars.selectors as cs\n\n# Get vectors of 2-letter country codes for each region of Oceania\noceania = {\n \"Australasia\": [\"AU\", \"NZ\"],\n \"Melanesia\": [\"NC\", \"PG\", \"SB\", \"VU\"],\n \"Micronesia\": [\"FM\", \"GU\", \"KI\", \"MH\", \"MP\", \"NR\", \"PW\"],\n \"Polynesia\": [\"PF\", \"WS\", \"TO\", \"TV\"],\n}\n\n# Create a dictionary mapping country to region (e.g. AU -> Australasia)\ncountry_to_region = {\n country: region for region, countries in oceania.items() for country in countries\n}\n\nwide_pops = (\n pl.from_pandas(countrypops)\n .filter(\n pl.col(\"country_code_2\").is_in(list(country_to_region))\n & pl.col(\"year\").is_in([2000, 2010, 2020])\n )\n .with_columns(pl.col(\"country_code_2\").replace(country_to_region).alias(\"region\"))\n .pivot(index=[\"country_name\", \"region\"], columns=\"year\", values=\"population\")\n .sort(\"2020\", descending=True)\n)\n\n(\n GT(wide_pops, rowname_col=\"country_name\", groupname_col=\"region\")\n .tab_header(title=\"Populations of Oceania's Countries in 2000, 2010, and 2020\")\n .tab_spanner(label=\"Total Population\", columns=cs.all())\n .fmt_integer()\n)\n\n\n\n\n\n\n \n Populations of Oceania's Countries in 2000, 2010, and 2020\n \n\n\n \n \n Total Population\n \n\n\n 2000\n 2010\n 2020\n\n\n \n Australasia\n \n \n Australia\n 19,028,802\n 22,031,750\n 25,655,289\n \n \n New Zealand\n 3,857,700\n 4,350,700\n 5,090,200\n \n \n Melanesia\n \n \n Papua New Guinea\n 5,508,297\n 7,583,269\n 9,749,640\n \n \n Solomon Islands\n 429,978\n 540,394\n 691,191\n \n \n Vanuatu\n 192,074\n 245,453\n 311,685\n \n \n New Caledonia\n 213,230\n 249,750\n 272,460\n \n \n Polynesia\n \n \n French Polynesia\n 250,927\n 283,788\n 301,920\n \n \n Samoa\n 184,008\n 194,672\n 214,929\n \n \n Tonga\n 102,603\n 107,383\n 105,254\n \n \n Tuvalu\n 9,638\n 10,550\n 11,069\n \n \n Micronesia\n \n \n Guam\n 160,188\n 164,905\n 169,231\n \n \n Kiribati\n 88,826\n 107,995\n 126,463\n \n \n Micronesia (Federated States)\n 111,709\n 107,588\n 112,106\n \n \n Northern Mariana Islands\n 80,338\n 54,087\n 49,587\n \n \n Marshall Islands\n 54,224\n 53,416\n 43,413\n \n \n Palau\n 19,726\n 18,540\n 17,972\n \n \n Nauru\n 10,377\n 10,241\n 12,315\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT, html\nfrom great_tables.data import towny\n\ntowny_mini = (\n towny[[\"name\", \"website\", \"density_2021\", \"land_area_km2\", \"latitude\", \"longitude\"]]\n .sort_values(\"density_2021\", ascending=False)\n .head(10)\n)\n\ntowny_mini[\"url_name\"] = [\"[\"] + towny_mini[\"name\"] + [\"]\"] + [\"(\"] + towny_mini[\"website\"] + [\")\"]\n\ntowny_mini[\"location\"] = (\n [\"[map](http://maps.google.com/?ie=UTF8&hq=&ll=\"]\n + towny_mini[\"latitude\"].astype(str)\n + [\",\"]\n + towny_mini[\"longitude\"].astype(str)\n + [\"&z=13)\"]\n)\n\n(\n GT(\n towny_mini[[\"url_name\", \"location\", \"land_area_km2\", \"density_2021\"]],\n rowname_col=\"url_name\",\n )\n .tab_header(\n title=\"The Municipalities of Ontario\",\n subtitle=\"The top 10 highest population density in 2021\",\n )\n .tab_stubhead(label=\"Municipality\")\n .fmt_markdown(columns=[\"url_name\", \"location\"])\n .fmt_number(columns=[\"land_area_km2\", \"density_2021\"], decimals=1)\n .cols_label(\n land_area_km2=html(\"land area, <br>km<sup>2</sup>\"),\n density_2021=html(\"density, <br>people/km<sup>2</sup>\"),\n )\n)\n\n\n\n\n\n\n \n The Municipalities of Ontario\n \n \n The top 10 highest population density in 2021\n \n\n\n Municipality\n location\n land area, km2\n density, people/km2\n\n\n \n Toronto\n map\n 631.1\n 4,427.8\n \n \n Brampton\n map\n 265.9\n 2,469.0\n \n \n Mississauga\n map\n 292.7\n 2,452.6\n \n \n Newmarket\n map\n 38.5\n 2,284.2\n \n \n Richmond Hill\n map\n 100.8\n 2,004.4\n \n \n Orangeville\n map\n 15.2\n 1,989.9\n \n \n Ajax\n map\n 66.6\n 1,900.8\n \n \n Waterloo\n map\n 64.1\n 1,895.7\n \n \n Kitchener\n map\n 136.8\n 1,877.7\n \n \n Guelph\n map\n 87.4\n 1,644.1\n \n\n\n\n\n\n\n \n\n\n\n\n\n\nShow the Code\nfrom great_tables import GT, html\nfrom great_tables.data import sza\nimport polars as pl\nimport polars.selectors as cs\n\nsza_pivot = (\n pl.from_pandas(sza)\n .filter((pl.col(\"latitude\") == \"20\") & (pl.col(\"tst\") <= \"1200\"))\n .select(pl.col(\"*\").exclude(\"latitude\"))\n .drop_nulls()\n .pivot(values=\"sza\", index=\"month\", columns=\"tst\", sort_columns=True)\n)\n\n(\n GT(sza_pivot, rowname_col=\"month\")\n .data_color(\n domain=[90, 0],\n palette=[\"rebeccapurple\", \"white\", \"orange\"],\n na_color=\"white\",\n )\n .tab_header(\n title=\"Solar Zenith Angles from 05:30 to 12:00\",\n subtitle=html(\"Average monthly values at latitude of 20°N.\"),\n )\n .sub_missing(missing_text=\"\")\n)\n\n\n\n\n\n\n \n Solar Zenith Angles from 05:30 to 12:00\n \n \n Average monthly values at latitude of 20°N.\n \n\n\n \n 0530\n 0600\n 0630\n 0700\n 0730\n 0800\n 0830\n 0900\n 0930\n 1000\n 1030\n 1100\n 1130\n 1200\n\n\n \n jan\n \n \n \n 84.9\n 78.7\n 72.7\n 66.1\n 61.5\n 56.5\n 52.1\n 48.3\n 45.5\n 43.6\n 43.0\n \n \n feb\n \n \n 88.9\n 82.5\n 75.8\n 69.6\n 63.3\n 57.7\n 52.2\n 47.4\n 43.1\n 40.0\n 37.8\n 37.2\n \n \n mar\n \n \n 85.7\n 78.8\n 72.0\n 65.2\n 58.6\n 52.3\n 46.2\n 40.5\n 35.5\n 31.4\n 28.6\n 27.7\n \n \n apr\n \n 88.5\n 81.5\n 74.4\n 67.4\n 60.3\n 53.4\n 46.5\n 39.7\n 33.2\n 26.9\n 21.3\n 17.2\n 15.5\n \n \n may\n \n 85.0\n 78.2\n 71.2\n 64.3\n 57.2\n 50.2\n 43.2\n 36.1\n 29.1\n 26.1\n 15.2\n 8.8\n 5.0\n \n \n jun\n 89.2\n 82.7\n 76.0\n 69.3\n 62.5\n 55.7\n 48.8\n 41.9\n 35.0\n 28.1\n 21.1\n 14.2\n 7.3\n 2.0\n \n \n jul\n 88.8\n 82.3\n 75.7\n 69.1\n 62.3\n 55.5\n 48.7\n 41.8\n 35.0\n 28.1\n 21.2\n 14.3\n 7.7\n 3.1\n \n \n aug\n \n 83.8\n 77.1\n 70.2\n 63.3\n 56.4\n 49.4\n 42.4\n 35.4\n 28.3\n 21.3\n 14.3\n 7.3\n 1.9\n \n \n sep\n \n 87.2\n 80.2\n 73.2\n 66.1\n 59.1\n 52.1\n 45.1\n 38.1\n 31.3\n 24.7\n 18.6\n 13.7\n 11.6\n \n \n oct\n \n \n 84.1\n 77.1\n 70.2\n 63.3\n 56.5\n 49.9\n 43.5\n 37.5\n 32.0\n 27.4\n 24.3\n 23.1\n \n \n nov\n \n \n 87.8\n 81.3\n 74.5\n 68.3\n 61.8\n 56.0\n 50.2\n 45.3\n 40.7\n 37.4\n 35.1\n 34.4\n \n \n dec\n \n \n \n 84.3\n 78.0\n 71.8\n 66.1\n 60.5\n 55.6\n 50.9\n 47.2\n 44.2\n 42.4\n 41.8\n \n\n\n\n\n\n\n \n\n\n\n\nView notebook ⬀\n\n\n\n\n\n\n \n Highest Paid Athletes in 2023\n \n\n \n Name\n icon\n Sport\n \n Earnings\n \n\n\n Total $M\n Off field $M\n Off field %\n\n\n\n 1\n Cristiano Ronaldo\n \n Soccer\n 136.0\n 90.0\n \n\n\n 2\n Lionel Messi\n \n Soccer\n 130.0\n 65.0\n \n\n\n 3\n Kylian Mbappé\n \n Soccer\n 120.0\n 20.0\n \n\n\n 4\n LeBron James\n \n Basketball\n 119.5\n 75.0\n \n\n\n 5\n Canelo Alvarez\n \n Boxing\n 110.0\n 10.0\n \n\n\n 6\n Dustin Johnson\n \n Golf\n 107.0\n 5.0\n \n\n\n 7\n Phil Mickelson\n \n Golf\n 106.0\n 2.0\n \n\n\n 8\n Stephen Curry\n \n Basketball\n 100.4\n 52.0\n \n\n\n 9\n Roger Federer\n \n Tennis\n 95.1\n 95.0\n \n\n\n \n \n \n Original table: @LisaHornung_ | Sports icons: Firza Alamsyah | Data: Forbes\n \n\n\n\n\n\n\n \n\n\n\n\n\nView source ⬀     Blog post (R code) ⬀\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n \n 2023 Mean Carbon Intensity (gCO2eq/kWh) and Power Consumption Breakdown (%)\n \n\n\n Zone\n CO2 Intensity\n Hydro\n Nuclear\n Wind\n Solar\n Geothermal\n Biomass\n Gas\n Coal\n Oil\n Unknown\n Hydro Discharge\n Battery Discharge\n\n\n \n Sweden\n 26\n 39.1%\n 26.8%\n 27.7%\n 0.1%\n 0.0%\n 0.4%\n 0.4%\n 0.8%\n 0.0%\n 4.6%\n 0.1%\n 0.0%\n \n \n Iceland\n 28\n 69.4%\n 0.0%\n 0.0%\n 0.0%\n 30.6%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n Quebec\n 35\n 90.1%\n 2.1%\n 4.4%\n 0.0%\n 0.0%\n 1.9%\n 1.4%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n France\n 46\n 12.3%\n 65.4%\n 10.3%\n 1.8%\n 0.0%\n 1.0%\n 7.1%\n 0.3%\n 0.3%\n 0.1%\n 1.4%\n 0.0%\n \n \n Ontario\n 104\n 23.3%\n 49.4%\n 8.7%\n 0.1%\n 0.0%\n 0.2%\n 18.1%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n New Zealand\n 106\n 60.5%\n 0.0%\n 7.7%\n 0.1%\n 19.0%\n 0.0%\n 6.8%\n 3.7%\n 0.0%\n 2.2%\n 0.0%\n 0.0%\n \n \n Finland\n 107\n 20.2%\n 36.5%\n 24.1%\n 0.1%\n 0.0%\n 6.2%\n 3.0%\n 8.1%\n 0.0%\n 1.8%\n 0.0%\n 0.0%\n \n \n South Australia\n 132\n 0.7%\n 0.0%\n 42.6%\n 33.7%\n 0.0%\n 0.0%\n 13.3%\n 9.0%\n 0.0%\n 0.0%\n 0.0%\n 0.7%\n \n \n Spain\n 132\n 17.1%\n 24.2%\n 25.1%\n 8.0%\n 0.0%\n 2.0%\n 18.8%\n 1.3%\n 0.2%\n 0.3%\n 3.0%\n 0.0%\n \n \n Belgium\n 147\n 1.3%\n 39.6%\n 25.2%\n 3.6%\n 0.0%\n 2.8%\n 19.4%\n 1.7%\n 0.1%\n 4.9%\n 1.2%\n 0.0%\n \n \n Tasmania\n 162\n 49.0%\n 0.0%\n 22.6%\n 10.8%\n 0.0%\n 0.0%\n 1.5%\n 16.1%\n 0.0%\n 0.0%\n 0.0%\n 0.0%\n \n \n East Denmark\n 184\n 6.4%\n 5.5%\n 48.4%\n 1.3%\n 0.0%\n 16.8%\n 7.7%\n 10.8%\n 1.4%\n 1.4%\n 0.4%\n 0.0%\n \n \n West Denmark\n 188\n 8.8%\n 2.2%\n 56.3%\n 1.6%\n 0.0%\n 7.6%\n 8.5%\n 13.0%\n 0.9%\n 0.4%\n 0.6%\n 0.0%\n \n \n Great Britain\n 214\n 3.8%\n 12.4%\n 35.9%\n 2.7%\n 0.0%\n 6.2%\n 35.1%\n 2.0%\n 0.0%\n 1.0%\n 1.0%\n 0.0%\n \n \n Netherlands\n 218\n 1.1%\n 3.9%\n 46.7%\n 10.8%\n 0.0%\n 4.6%\n 22.4%\n 8.6%\n 0.8%\n 1.1%\n 0.2%\n 0.0%\n \n \n New York ISO\n 275\n 23.7%\n 22.8%\n 4.9%\n 0.0%\n 0.0%\n 0.1%\n 46.9%\n 0.0%\n 0.0%\n 1.6%\n 0.0%\n 0.0%\n \n \n Italy (North)\n 307\n 22.7%\n 14.5%\n 3.9%\n 2.9%\n 0.2%\n 3.1%\n 38.4%\n 1.5%\n 0.2%\n 9.3%\n 3.3%\n 0.0%\n \n \n California\n 328\n 8.4%\n 12.7%\n 7.9%\n 12.0%\n 3.0%\n 1.8%\n 48.5%\n 2.1%\n 0.0%\n 1.2%\n 0.0%\n 2.6%\n \n \n Germany\n 389\n 4.4%\n 2.8%\n 39.7%\n 3.3%\n 0.0%\n 8.7%\n 14.4%\n 23.3%\n 0.6%\n 0.6%\n 2.1%\n 0.0%\n \n \n Ireland\n 389\n 3.7%\n 0.8%\n 38.5%\n 0.2%\n 0.0%\n 2.5%\n 42.4%\n 9.7%\n 2.0%\n 0.1%\n 0.1%\n 0.0%\n \n \n Western Australia\n 417\n 0.0%\n 0.0%\n 14.1%\n 33.8%\n 0.0%\n 0.3%\n 24.2%\n 27.1%\n 0.3%\n 0.0%\n 0.0%\n 0.3%\n \n \n Texas\n 432\n 0.0%\n 9.1%\n 22.3%\n 6.0%\n 0.0%\n 0.0%\n 46.1%\n 16.1%\n 0.0%\n 0.4%\n 0.0%\n 0.0%\n \n \n Alberta\n 447\n 1.9%\n 0.0%\n 12.4%\n 1.1%\n 0.0%\n 2.5%\n 70.7%\n 7.2%\n 0.0%\n 4.1%\n 0.0%\n 0.0%\n \n \n Victoria\n 508\n 3.9%\n 0.0%\n 17.5%\n 19.0%\n 0.0%\n 0.0%\n 0.3%\n 59.1%\n 0.0%\n 0.0%\n 0.0%\n 0.2%\n \n \n New South Wales\n 578\n 3.2%\n 0.0%\n 9.5%\n 23.7%\n 0.0%\n 0.2%\n 0.7%\n 62.6%\n 0.0%\n 0.0%\n 0.0%\n 0.1%\n \n \n Queensland\n 662\n 1.9%\n 0.0%\n 3.8%\n 21.1%\n 0.0%\n 0.0%\n 7.2%\n 65.7%\n 0.2%\n 0.0%\n 0.0%\n 0.1%\n \n \n South Africa\n 685\n 2.2%\n 4.3%\n 5.8%\n 3.8%\n 0.0%\n 0.0%\n 0.0%\n 79.9%\n 2.0%\n 0.1%\n 2.0%\n 0.0%\n \n \n India (North)\n 693\n 9.3%\n 2.2%\n 0.1%\n 10.6%\n 0.0%\n 0.0%\n 1.8%\n 75.2%\n 0.0%\n 0.9%\n 0.0%\n 0.0%\n \n\n \n \n \n Source: api.electricitymap.org | Methodology: https://www.electricitymaps.com/methodology. Some emissions factors are based on IPCC 2014 defaults, while some are based on more accurate regional factors. All zones are publicly available on the Carbon intensity and emission factors tab via Google docs link\n \n\n\n\n\n\n\n \n\n\n\n\nView source ⬀     Notebook ⬀\n\n\nShow the Code\nimport polars as pl\nimport polars.selectors as cs\nfrom great_tables import GT, loc, style\n\ncoffee_sales = pl.read_json(\"./_data/coffee-sales.json\")\n\nsel_rev = cs.starts_with(\"revenue\")\nsel_prof = cs.starts_with(\"profit\")\n\n# yo\n\ncoffee_table = (\n GT(coffee_sales)\n .tab_header(\"Sales of Coffee Equipment\")\n .tab_spanner(label=\"Revenue\", columns=sel_rev)\n .tab_spanner(label=\"Profit\", columns=sel_prof)\n .cols_label(\n revenue_dollars=\"Amount\",\n profit_dollars=\"Amount\",\n revenue_pct=\"Percent\",\n profit_pct=\"Percent\",\n monthly_sales=\"Monthly Sales\",\n icon=\"\",\n product=\"Product\",\n )\n # formatting ----\n .fmt_number(\n columns=cs.ends_with(\"dollars\"),\n compact=True,\n pattern=\"${x}\",\n n_sigfig=3,\n )\n .fmt_percent(columns=cs.ends_with(\"pct\"), decimals=0)\n # style ----\n .tab_style(\n style=style.fill(color=\"aliceblue\"),\n locations=loc.body(columns=sel_rev),\n )\n .tab_style(\n style=style.fill(color=\"papayawhip\"),\n locations=loc.body(columns=sel_prof),\n )\n .tab_style(\n style=style.text(weight=\"bold\"),\n locations=loc.body(rows=pl.col(\"product\") == \"Total\"),\n )\n .fmt_nanoplot(\"monthly_sales\", plot_type=\"bar\")\n .fmt_image(\"icon\", path=\"_data/coffee-table-icons/\")\n .sub_missing(missing_text=\"\")\n)\n\ncoffee_table\n\n\n\n\n\n\n \n Sales of Coffee Equipment\n \n\n\n \n Product\n \n Revenue\n \n \n Profit\n \n Monthly Sales\n\n\n Amount\n Percent\n Amount\n Percent\n\n\n \n \n Grinder\n $904K\n 3%\n $568K\n 4%\n 7650521494596613667748765686607594568751\n \n \n \n Moka pot\n $2.05M\n 7%\n $181K\n 1%\n 6.87K04.73K4.74K4.79K5.51K6.16K6.62K6.87K6.03K5.30K4.88K4.65K6.28K\n \n \n \n Cold brew\n $289K\n 1%\n $242K\n 2%\n 2.70K02442494389811.77K2.70K2.61K2.35K1.74K896499244\n \n \n \n Filter\n $404K\n 1%\n $70.0K\n 0%\n 2.74K02.07K1.81K1.84K2.12K2.25K2.63K2.56K2.37K2.16K2.19K2.07K2.74K\n \n \n \n Drip machine\n $2.63M\n 9%\n $1.37M\n 9%\n 2.58K02.14K1.62K1.97K2.10K2.58K2.46K2.34K2.32K2.05K1.97K1.84K2.33K\n \n \n \n AeroPress\n $2.60M\n 9%\n $1.29M\n 9%\n 9.27K06.33K5.20K6.37K7.02K7.91K8.70K8.69K7.80K6.83K6.96K6.88K9.27K\n \n \n \n Pour over\n $846K\n 3%\n $365K\n 2%\n 2.18K01.56K1.29K1.51K1.69K1.94K2.18K2.14K1.86K1.72K1.81K1.60K2.16K\n \n \n \n French press\n $1.11M\n 4%\n $748K\n 5%\n 4.82K03.51K2.88K3.35K3.79K3.90K4.10K4.18K4.43K3.28K3.42K3.30K4.82K\n \n \n \n Cezve\n $2.51M\n 9%\n $1.97M\n 13%\n 17.1K012.2K11.5K11.8K13.6K15.4K16.5K17.1K14.4K13.0K12.9K11.6K15.9K\n \n \n \n Chemex\n $3.14M\n 11%\n $818K\n 6%\n 7.22K04.94K4.17K5.24K6.00K6.36K6.77K7.11K6.25K5.60K6.08K4.98K7.22K\n \n \n \n Scale\n $3.80M\n 13%\n $2.91M\n 20%\n 3.18K01.54K1.57K1.68K2.03K2.42K2.55K2.57K2.23K2.04K2.09K1.69K3.18K\n \n \n \n Kettle\n $756K\n 3%\n $618K\n 4%\n 1.53K01.14K1.02K1.09K1.13K1.41K1.48K1.46K1.30K1.14K1.23K1.19K1.53K\n \n \n \n Espresso Machine\n $8.41M\n 29%\n $3.64M\n 25%\n 2.58K06868406185982.15K5337979961.00K6688582.58K\n \n \n \n Total\n $29.4M\n 102%\n $14.8M\n 100%" } ] \ No newline at end of file