I have the following dataframe;
A B StartTime EndTime
r t 2018-06-11 00:00:00 2018-12-16 00:00:00
d g 2018-06-22 05:30:00 2018-12-01 00:00:00
r g 2018-09-10 08:00:00 2023-01-01 00:00:00
e d 2018-09-26 23:00:00 2019-02-07 23:00:00
.
.
.
y h 2018-09-30 23:00:00
I need to add an extra column 'DayNight' based off whether or not the 'Start Time' starts at day or night.
early = 06:00:00
late = 17:59:00
if df['Start Date'] > early and df['Start Date'] < late:
df['DayNight'] = 'Day'
else:
df['DayNight'] = 'Night'
I'm trying to write an if statement but struggling on how to define a time without losing the dates.
Any help would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire