Untitled
unknown
plain_text
3 years ago
1.2 kB
9
Indexable
p = pd.read_csv("Occupancy_Estimation.csv", delimiter=",") light=p[["Room_Occupancy_Count", "S1_Light","S2_Light","S3_Light","S4_Light","Time"]] sound=p[["Room_Occupancy_Count", "S1_Sound","S2_Sound","S3_Sound","S4_Sound","Time"]] p["Datetime"] = p["Date"] + ' '+ p["Time"] p["Timestamp"]=pd.to_datetime(p["Time"], format = "%H:%M:%S").dt.time p["Hour"]=pd.to_datetime(p["Time"], format = "%H:%M:%S").dt.hour p["Datetime"] = pd.to_datetime(p["Datetime"], format = "%Y/%m/%d %H:%M:%S") print(p["Datetime"]) def transformTime(x): if (x > 4) and (x <= 8): return 'Early Morning (Later than 4AM and sooner than or equal to 8 AM)' elif (x > 8) and (x <= 12 ): return 'Morning (Later than 8 AM and sooner than or equal to 12 AM)' elif (x > 12) and (x <= 16): return'Noon (Later than 12PM and sooner than or equal to 16 PM)' elif (x > 16) and (x <= 20) : return 'Eve (Later than 16PM and sooner than or equal to 20 PM)' elif (x > 20) and (x <= 24): return'Night (Later than 20 PM and sooner than or equal to 12AM)' elif (x <= 4): return'Late Night (Sooner than or equal to 4 AM)' p['TimeOfTheDay'] = p["Hour"].apply(transformTime)
Editor is loading...