df[‘logTime’] = pd.to_datetime(df[‘logTime’]).dt.floor(‘H’).dt.time
I tried to convert the datatime object. when I used jupyter it what I want, but when I deployed to streamlit I get numbers. ?
how to return the time object properly.
below what I get in jupyter

If you’re looking for a specific output format, your best bet is to use strftime to specify it
import pandas as pd
import streamlit as st
# Make dataframe with a logTime column containing time strings
df = pd.DataFrame(
{
"logTime": [
"02:01:00.000000000",
"03:02:00.000000000",
"04:03:00.000000000",
"05:04:00.000000000",
]
}
)
st.write(df)
df["logTime"] = pd.to_datetime(df["logTime"]).dt.floor("H").dt.strftime("%H:%M:%S")
st.write(df)
Which yields
2 Likes
Waw, Hello, thank you . you really saved my day