Converting object to pd.datetime went wrong, differ from I get in Jupyter notebook

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": [


df["logTime"] = pd.to_datetime(df["logTime"]).dt.floor("H").dt.strftime("%H:%M:%S")


Which yields

1 Like