Arata Takaoka
Arata Takaoka

Reputation: 11

How to add a date for a specific time

For a dataframe like the one below, I want to add one day to the date only in the 0:00 time zone. Is there any way to do it?

df.head(50)

example]

Upvotes: 1

Views: 48

Answers (1)

Joran Beasley
Joran Beasley

Reputation: 113988

# create a mask for all entries with midnight as their time
row_mask = (df['timezone'].dt.hour == 0) & (df['timezone'].dt.minute == 0)
#now apply it
df.loc[row_mask,'timezone'] = df[row_mask]['timezone'] + datetime.timedelta(days=1)

Upvotes: 1

Related Questions