Skip to content

Instantly share code, notes, and snippets.

@cpard
Created May 28, 2016 22:09
Show Gist options
  • Save cpard/e8b5282cfbf0d7fa316a5b12125c9669 to your computer and use it in GitHub Desktop.
Save cpard/e8b5282cfbf0d7fa316a5b12125c9669 to your computer and use it in GitHub Desktop.
Find out in which part of the day the event occured
padas.concat([joinedEventsFrame,padas.DataFrame(padas.DatetimeIndex(joinedEventsFrame['timestamp']).hour,index = joinedEventsFrame.index, columns=['hours'])],axis=1)
def occuredAt(time):
result = np.nan
if time >=9 and time <= 17:
result = 'during'
elif time >= 0 and time < 9:
result = 'before'
elif time > 17 and time <24:
result = 'after'
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment