Hello!
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!
Hello!
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!
Hi @fredyonge and welcome to the forum
,
You can use df.style.format function like so:
import streamlit as st
import pandas as pd
from datetime import datetime
data = {"a": [datetime.now()], "b": [datetime.now().timestamp()]}
df = pd.DataFrame(data, columns=["a", "b"])
fmt = "%d-%m-%Y %H:%M:%S"
styler = df.style.format(
{
"a": lambda t: t.strftime(fmt),
"b": lambda t: datetime.fromtimestamp(t).strftime(fmt),
}
)
st.table(styler)
Please feel free to let us know if you need any additional help.
And thanks for using Streamlit!