I have a column named "date_time" which has date and time stamp of some year, I want to find which part of the day does this time fall into, like morning, noon, evening and night for extracting the features as below :
if date_time.dt.hour >=5 and new_data.current_date_time.dt.hour <12 --> then it's morning if date_time.dt.hour >=12 and new_data.current_date_time.dt.hour<17 --> then noon if date_time.dt.hour >=17 and new_data.current_date_time.dt.hour<20 --. then evening else night.
But I'm unable to filter as above using .dt.hour attribute of the pandas to_datetime datatype, please help me in achieving this.