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!
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.