Skip to content

Data Bars

bar(in_col, scope="column", color=None, fill="steelblue", fill_pos=None, fill_neg=None, exclude=None)

Add in-cell bar charts using CSS gradients. Bar width is proportional to the value. For signed data, use fill_pos and fill_neg to colour positive and negative bars differently.

  • in_col str | list | Expr — Column(s) to apply to
  • scope "column" | "table", default "column" — Compute max per column or across all selected
  • color str | None, default None — Text colour
  • fill str, default "steelblue" — Bar colour (used when fill_pos/fill_neg are not set)
  • fill_pos str | None, default None — Bar colour for positive values (enables signed mode)
  • fill_neg str | None, default None — Bar colour for negative values
  • exclude str | list | None, default None — Columns to exclude

Example — standard bars:

df.style().bar("Revenue").show()
Company Revenue Profit Growth Employees_k
Apple 383.3 97.0 7.8 161
Microsoft 211.9 72.4 6.9 221
Google 307.4 73.8 8.7 182
Amazon 574.8 30.4 11.8 1541
Meta 134.9 39.1 16.4 67

Example — signed bars (positive/negative):

df.style().bar(
    "Temp_Anomaly",
    fill_pos="steelblue",
    fill_neg="#FF6347"
).show()
Decade Temp_Anomaly CO2_ppm Sea_Level_mm Arctic_Ice_M_km2
1880s -0.27 290 0 7.5
1910s -0.27 300 10 7.4
1940s 0.05 310 30 7.3
1970s 0.01 326 50 7.2
1990s 0.33 354 90 6.8
2000s 0.62 377 150 6.2
2010s 0.93 395 210 5.1
2020s 1.17 417 250 4.7