Here are tables made with Great Tables, from small ones to elaborate ones, with the code that makes each of them under Show the Code. Borrow whatever you like for tables of your own.
Show the Code
import polars as plfrom great_tables import GT, md, htmlfrom great_tables.data import countrypopscountries_mini = ( pl.from_pandas(countrypops) .filter(pl.col("year") ==2022) .sort("population", descending=True) .select("country_name", "population") .head(10))( GT(countries_mini) .tab_header( title="The World's Most Populous Countries", subtitle="The top ten in 2022 are presented" ) .tab_stub(rowname_col="country_name") .tab_source_note( source_note="Total population counts all residents regardless of legal status or citizenship." ) .tab_source_note( source_note=md("Source: [The World Bank](https://data.worldbank.org/indicator/SP.POP.TOTL).") ) .tab_stubhead(label="country") .fmt_integer(columns="population"))
The World's Most Populous Countries
The top ten in 2022 are presented
country
population
India
1,417,173,173
China
1,412,175,000
United States
333,287,557
Indonesia
275,501,339
Pakistan
235,824,862
Nigeria
218,541,212
Brazil
215,313,498
Bangladesh
171,186,372
Russian Federation
143,555,736
Mexico
127,504,125
Total population counts all residents regardless of legal status or citizenship.
from great_tables import GT, htmlfrom great_tables.data import gibraltargibraltar_mini = gibraltar.head(10)[["temp", "humidity", "wind_speed", "pressure", "date", "time"]]( GT(gibraltar_mini) .tab_header( title="Weather at Gibraltar Airport", subtitle="Observations from the early hours of May 1, 2023" ) .tab_spanner( label="Observed", columns=["date", "time"] ) .tab_spanner( label="Measurement", columns=["temp", "humidity", "wind_speed", "pressure"] ) .cols_move_to_start(columns=["date", "time"]) .fmt_percent(columns="humidity", decimals=0) .cols_label( date ="Date", time ="Time", temp = html("Temp,<br>°C"), humidity ="Humidity", wind_speed = html("Wind,<br>m s<sup>−1</sup>"), pressure = html("Pressure,<br>hPa") ))
Weather at Gibraltar Airport
Observations from the early hours of May 1, 2023
Observed
Measurement
Date
Time
Temp, °C
Humidity
Wind, m s−1
Pressure, hPa
2023-05-01
00:20
18.9
68%
6.7
1015.2
2023-05-01
00:50
18.9
73%
7.2
1015.2
2023-05-01
01:20
17.8
77%
6.7
1014.6
2023-05-01
01:50
18.9
73%
6.7
1014.6
2023-05-01
02:20
18.9
68%
6.7
1014.6
2023-05-01
02:50
17.8
73%
6.7
1014.6
2023-05-01
03:20
17.8
73%
7.2
1014.6
2023-05-01
03:50
17.8
73%
6.3
1013.5
2023-05-01
04:20
18.9
64%
4.0
1014.6
2023-05-01
04:50
18.9
64%
3.1
1014.6
Show the Code
from great_tables import GTfrom great_tables.data import countrypopsimport polars as plimport polars.selectors as cs# Get vectors of 2-letter country codes for each region of Oceaniaoceania = {"Australasia": ["AU", "NZ"],"Melanesia": ["NC", "PG", "SB", "VU"],"Micronesia": ["FM", "GU", "KI", "MH", "MP", "NR", "PW"],"Polynesia": ["PF", "WS", "TO", "TV"],}# Create a dictionary mapping country to region (e.g. AU -> Australasia)country_to_region = { country: region for region, countries in oceania.items() for country in countries}wide_pops = ( pl.from_pandas(countrypops) .filter( pl.col("country_code_2").is_in(list(country_to_region))& pl.col("year").is_in([2000, 2010, 2020]) ) .with_columns(pl.col("country_code_2").replace(country_to_region).alias("region")) .pivot(index=["country_name", "region"], on="year", values="population") .sort("2020", descending=True))( GT(wide_pops) .tab_header(title="Populations of Oceania's Countries in 2000, 2010, and 2020") .tab_spanner(label="Total Population", columns=cs.all()) .tab_stub(rowname_col="country_name", groupname_col="region") .fmt_integer())
Populations of Oceania's Countries in 2000, 2010, and 2020
2023 Mean Carbon Intensity (gCO2eq/kWh) and Power Consumption Breakdown (%)
Zone
CO2 Intensity
Hydro
Nuclear
Wind
Solar
Geothermal
Biomass
Gas
Coal
Oil
Unknown
Hydro Discharge
Battery Discharge
Sweden
26
39.1%
26.8%
27.7%
0.1%
0.0%
0.4%
0.4%
0.8%
0.0%
4.6%
0.1%
0.0%
Iceland
28
69.4%
0.0%
0.0%
0.0%
30.6%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
Quebec
35
90.1%
2.1%
4.4%
0.0%
0.0%
1.9%
1.4%
0.0%
0.0%
0.0%
0.0%
0.0%
France
46
12.3%
65.4%
10.3%
1.8%
0.0%
1.0%
7.1%
0.3%
0.3%
0.1%
1.4%
0.0%
Ontario
104
23.3%
49.4%
8.7%
0.1%
0.0%
0.2%
18.1%
0.0%
0.0%
0.0%
0.0%
0.0%
New Zealand
106
60.5%
0.0%
7.7%
0.1%
19.0%
0.0%
6.8%
3.7%
0.0%
2.2%
0.0%
0.0%
Finland
107
20.2%
36.5%
24.1%
0.1%
0.0%
6.2%
3.0%
8.1%
0.0%
1.8%
0.0%
0.0%
South Australia
132
0.7%
0.0%
42.6%
33.7%
0.0%
0.0%
13.3%
9.0%
0.0%
0.0%
0.0%
0.7%
Spain
132
17.1%
24.2%
25.1%
8.0%
0.0%
2.0%
18.8%
1.3%
0.2%
0.3%
3.0%
0.0%
Belgium
147
1.3%
39.6%
25.2%
3.6%
0.0%
2.8%
19.4%
1.7%
0.1%
4.9%
1.2%
0.0%
Tasmania
162
49.0%
0.0%
22.6%
10.8%
0.0%
0.0%
1.5%
16.1%
0.0%
0.0%
0.0%
0.0%
East Denmark
184
6.4%
5.5%
48.4%
1.3%
0.0%
16.8%
7.7%
10.8%
1.4%
1.4%
0.4%
0.0%
West Denmark
188
8.8%
2.2%
56.3%
1.6%
0.0%
7.6%
8.5%
13.0%
0.9%
0.4%
0.6%
0.0%
Great Britain
214
3.8%
12.4%
35.9%
2.7%
0.0%
6.2%
35.1%
2.0%
0.0%
1.0%
1.0%
0.0%
Netherlands
218
1.1%
3.9%
46.7%
10.8%
0.0%
4.6%
22.4%
8.6%
0.8%
1.1%
0.2%
0.0%
New York ISO
275
23.7%
22.8%
4.9%
0.0%
0.0%
0.1%
46.9%
0.0%
0.0%
1.6%
0.0%
0.0%
Italy (North)
307
22.7%
14.5%
3.9%
2.9%
0.2%
3.1%
38.4%
1.5%
0.2%
9.3%
3.3%
0.0%
California
328
8.4%
12.7%
7.9%
12.0%
3.0%
1.8%
48.5%
2.1%
0.0%
1.2%
0.0%
2.6%
Germany
389
4.4%
2.8%
39.7%
3.3%
0.0%
8.7%
14.4%
23.3%
0.6%
0.6%
2.1%
0.0%
Ireland
389
3.7%
0.8%
38.5%
0.2%
0.0%
2.5%
42.4%
9.7%
2.0%
0.1%
0.1%
0.0%
Western Australia
417
0.0%
0.0%
14.1%
33.8%
0.0%
0.3%
24.2%
27.1%
0.3%
0.0%
0.0%
0.3%
Texas
432
0.0%
9.1%
22.3%
6.0%
0.0%
0.0%
46.1%
16.1%
0.0%
0.4%
0.0%
0.0%
Alberta
447
1.9%
0.0%
12.4%
1.1%
0.0%
2.5%
70.7%
7.2%
0.0%
4.1%
0.0%
0.0%
Victoria
508
3.9%
0.0%
17.5%
19.0%
0.0%
0.0%
0.3%
59.1%
0.0%
0.0%
0.0%
0.2%
New South Wales
578
3.2%
0.0%
9.5%
23.7%
0.0%
0.2%
0.7%
62.6%
0.0%
0.0%
0.0%
0.1%
Queensland
662
1.9%
0.0%
3.8%
21.1%
0.0%
0.0%
7.2%
65.7%
0.2%
0.0%
0.0%
0.1%
South Africa
685
2.2%
4.3%
5.8%
3.8%
0.0%
0.0%
0.0%
79.9%
2.0%
0.1%
2.0%
0.0%
India (North)
693
9.3%
2.2%
0.1%
10.6%
0.0%
0.0%
1.8%
75.2%
0.0%
0.9%
0.0%
0.0%
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