Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change time in timestamp

I have some timestamps in python pandas, Timestamp('2000-02-09 00:00:00') and I would like to convert them to Timestamp('2000-02-09 13:00:00'). Just adding 13 hours wouldn't work as some of them have different time. Can you point to a solution to this problem?

like image 610
NickD1 Avatar asked Jan 18 '26 16:01

NickD1


1 Answers

Use replace method of pandas timestamp objects:

import pandas as pd
t = pd.Timestamp('2000-02-09 00:00:00')
t = t.replace(hour=13, minute=0, second=0)
like image 149
Anton Protopopov Avatar answered Jan 21 '26 06:01

Anton Protopopov