Format with function in st.dataframe()

Afaik the format kwarg in NumberColumn is limited to the “printf-style” formatters shown in the docs. However, the dataframe could be preformatted with your custom function using pandas’ style.format, without it losing the other columns’ customization.

image

st.dataframe(
    df.style.format({"stars": human_format}),   # Preformat
    column_config={
        "name": "App name",
        "stars": st.column_config.NumberColumn(   # Keep as number :)
            "Github Stars",
            help="Number of stars on GitHub",
        ),
        "url": st.column_config.LinkColumn("App URL"),
        "views_history": st.column_config.LineChartColumn(
            "Views (past 30 days)", y_min=0, y_max=5000
        ),
    },
    hide_index=True,
)