Fixed the time first and last conversation features bug.
parent
b3b16bdb73
commit
622d2997c3
|
@ -81,16 +81,18 @@ 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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue