loc.footnotes

Target the footnotes section of the footer.

Usage

Source

loc.footnotes()

With loc.footnotes(), we can target only the footnotes in the table’s footer. This is useful when applying custom styling with the tab_style() method. That method has a locations= argument and this class should be used there to perform the targeting. The ‘footnotes’ location is generated by tab_footnote(). To target both the footnotes and source notes sections together, use loc.footer() instead.

Returns

LocFootnotes
A LocFootnotes object, which is used for a locations= argument if specifying the footnotes section.

Examples

Let’s use a subset of the gtcars dataset in a new table. We’ll add a footnote (with tab_footnote()) and a source note, then style only the footnotes section inside tab_style() with locations=loc.footnotes().

from great_tables import GT, style, loc
from great_tables.data import gtcars

gtcars_mini = gtcars[["mfr", "model", "msrp"]].head(5)

(
    GT(gtcars_mini)
    .tab_footnote(
        footnote="Prices in USD.",
        locations=loc.column_labels(columns="msrp")
    )
    .tab_source_note(source_note="From edmunds.com")
    .tab_style(
        style=style.fill(color="#FFFFDD"),
        locations=loc.footnotes()
    )
)
mfr model msrp1
Ford GT 447000.0
Ferrari 458 Speciale 291744.0
Ferrari 458 Spider 263553.0
Ferrari 458 Italia 233509.0
Ferrari 488 GTB 245400.0
From edmunds.com
1 Prices in USD.

Styling footnotes separately from source notes lets you visually distinguish the two sections. Here we apply different background fills to each.

(
    GT(gtcars_mini)
    .tab_footnote(
        footnote="Prices in USD.",
        locations=loc.column_labels(columns="msrp")
    )
    .tab_footnote(
        footnote="All models from 2017.",
        locations=None
    )
    .tab_source_note(source_note="From edmunds.com")
    .tab_style(
        style=style.fill(color="#FFFFDD"),
        locations=loc.footnotes()
    )
    .tab_style(
        style=style.fill(color="#DDECFF"),
        locations=loc.source_notes()
    )
)
mfr model msrp1
Ford GT 447000.0
Ferrari 458 Speciale 291744.0
Ferrari 458 Spider 263553.0
Ferrari 458 Italia 233509.0
Ferrari 488 GTB 245400.0
From edmunds.com
All models from 2017.
1 Prices in USD.