zeerock
zeerock

Reputation: 93

how to remove milliseconds or decimals in a specific dataframe column

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

Upvotes: 0

Views: 945

Answers (2)

LOR13
LOR13

Reputation: 83

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

Upvotes: 1

zeerock
zeerock

Reputation: 93

I convert the timestamp into datetime format

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

Upvotes: 0

Related Questions