great_tables
  • Get Started
  • Examples
  • Reference
  • Blog

On this page

  • Returns
  • Examples

loc.source_notes

loc.source_notes()

Target the source notes.

With loc.source_notes(), we can target the source notes in the table. This is useful when applying custom with the tab_style() method. That method has a locations= argument and this class should be used there to perform the targeting. The ‘source_notes’ location is generated by tab_source_note().

Returns

: LocSourceNotes

A LocSourceNotes object, which is used for a locations= argument if specifying the source notes.

Examples

Let’s use a subset of the gtcars dataset in a new table. Add a source note (with tab_source_note() and style the source notes section inside tab_style() with locations=loc.source_notes().

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

(
    GT(gtcars[["mfr", "model", "msrp"]].head(5))
    .tab_source_note(source_note="From edmunds.com")
    .tab_style(
        style=style.text(color="blue", size="small", weight="bold"),
        locations=loc.source_notes()
    )
)
mfr model msrp
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