Change the way date get displayed in a table from a pandas dataframe


currently the date from a pandas dataframe in st.table(dataframe) gets displayed this way:

I would like to display it YYYY-MM-DD HH:MM

Thanks for your help!

1 Like

Hi @fredyonge and welcome to the forum :wave:,

You can use function like so:

import streamlit as st
import pandas as pd
from datetime import datetime

data = {"a": [], "b": []}
df = pd.DataFrame(data, columns=["a", "b"])

fmt = "%d-%m-%Y %H:%M:%S"
styler =
        "a": lambda t: t.strftime(fmt),
        "b": lambda t: datetime.fromtimestamp(t).strftime(fmt),

Please feel free to let us know if you need any additional help.
And thanks for using Streamlit!