Fixed the time first and last conversation features bug.

pull/95/head
nikunjgoel95 2020-08-13 12:45:08 -04:00
parent b3b16bdb73
commit 622d2997c3
1 changed files with 9 additions and 7 deletions

View File

@ -81,19 +81,21 @@ def base_conversation_features(conversation_data, day_segment, requested_feature
conversation_features["conversation_" + day_segment + "_maxconversationduration"] = conversation_data.groupby(["local_date"])["conv_duration"].max() conversation_features["conversation_" + day_segment + "_maxconversationduration"] = conversation_data.groupby(["local_date"])["conv_duration"].max()
if "timefirstconversation" in features_to_compute: if "timefirstconversation" in features_to_compute:
timeFirstConversation = conversation_data[conversation_data["double_convo_start"] > 0].groupby(["local_date"])[["double_convo_start","local_hour","local_minute"]].min() timeFirstConversation = conversation_data[conversation_data["double_convo_start"] > 0].groupby(["local_date"])['local_time'].min()
if "local_hour" in timeFirstConversation.columns: if len(list(timeFirstConversation.index)) > 0:
conversation_features["conversation_" + day_segment + "_timefirstconversation"] = timeFirstConversation["local_hour"]*60 + timeFirstConversation["local_minute"] for date in list(timeFirstConversation.index):
conversation_features.loc[date,"conversation_" + day_segment + "_timefirstconversation"] = int(timeFirstConversation.loc[date].split(':')[0])*60 + int(timeFirstConversation.loc[date].split(':')[1])
else: else:
conversation_features["conversation_" + day_segment + "_timefirstconversation"] = 0 conversation_features["conversation_" + day_segment + "_timefirstconversation"] = 0
if "timelastconversation" in features_to_compute: if "timelastconversation" in features_to_compute:
timeLastConversation = conversation_data[conversation_data["double_convo_start"] > 0].groupby(["local_date"])[["double_convo_start","local_hour","local_minute"]].max() timeLastConversation = conversation_data[conversation_data["double_convo_start"] > 0].groupby(["local_date"])['local_time'].max()
if "local_hour" in timeLastConversation: if len(list(timeLastConversation.index)) > 0:
conversation_features["conversation_" + day_segment + "_timelastconversation"] = timeLastConversation["local_hour"]*60 + timeLastConversation["local_minute"] for date in list(timeLastConversation.index):
conversation_features.loc[date,"conversation_" + day_segment + "_timelastconversation"] = int(timeLastConversation.loc[date].split(':')[0])*60 + int(timeLastConversation.loc[date].split(':')[1])
else: else:
conversation_features["conversation_" + day_segment + "_timelastconversation"] = 0 conversation_features["conversation_" + day_segment + "_timelastconversation"] = 0
if "sumenergy" in features_to_compute: if "sumenergy" in features_to_compute:
conversation_features["conversation_" + day_segment + "_sumenergy"] = conversation_data.groupby(["local_date"])["double_energy"].sum() conversation_features["conversation_" + day_segment + "_sumenergy"] = conversation_data.groupby(["local_date"])["double_energy"].sum()