Home > front end >  how to remove milliseconds or decimals in a specific dataframe column
how to remove milliseconds or decimals in a specific dataframe column

Time:05-13

I have 2 columns containing date and time(hr,min,seconds:milliseconds) How do I remove the milliseconds from only one of the column?

Name   MinTime                       MaxTime
John   2020-02-20 12:00:00.12345     2020-02-20 12:00:00.12345

Desired Output
Name   MinTime                       MaxTime
John   2020-02-20 12:00:00     2020-02-20 12:00:00.12345

CodePudding user response:

df.MinTime = df.MinTime.replace(microsecond=0)

CodePudding user response:

I convert the timestamp into datetime format

df['MinTime']=pd.to_datetime(df['MinTime'])
df['MinTime'] = df['MinTime'].astype('datetime64[s]')
  • Related