Skip to content

Commit

Permalink
add volume on week/hour basis
Browse files Browse the repository at this point in the history
  • Loading branch information
weallwegot committed Apr 6, 2017
1 parent 7aee230 commit 9bf656b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .coveragerc to control coverage.py
[run]
source = src
omit = *__init__.py,unused,*main.py
omit = *__init__.py,unused,*main.py,*main.html
branch = False
6 changes: 3 additions & 3 deletions main.html

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

r = mc.calculate_all_metrics(full_tes)

###################################
## Convert Emoji To Readable ##
###################################
ub = utils.UtilityBoss()


Expand All @@ -71,6 +74,21 @@

output_file("main.html")

print(str(zzz['hours_df']))

print(str(zzz['days_df']))

target = open('data_frame_table.txt','w')
target.write("Hours DF: " + str(zzz['hours_df']))
target.write("Days DF: " + str(zzz['days_df']))

target.close()

p_vol_hr = Bar(data=zzz['hours_df'],label='hour_x',group='participant',values='texts_sent',
title='Number of Texts Sent By Time of Day',legend='top_right',ylabel='Number of Texts Sent')

p_vol_day = Bar(data=zzz['days_df'],label='day_x',group='participant',values='texts_sent',
title='Number of Texts Sent By Day of Week',legend='top_right',ylabel='Number of Texts Sent')

p_waits_hr = Bar(data=zzz['hours_df'],label='hour_x',group='participant',values='wait_time',
title='Wait Times By Time of Day',legend='top_right',ylabel='Wait Time (sec)')
Expand Down Expand Up @@ -133,6 +151,8 @@

allplots = vplot(p_waits_hr,
p_waits_day,
p_vol_day,
p_vol_hr,
plot_volume_cumsum,
plot_volume,
p_emoji_day,
Expand Down
15 changes: 12 additions & 3 deletions src/data_viz/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def create_time_trends(tes_list):
double_day_s2 = []
top_ems_day_s1 = []
top_ems_day_s2 = []
volume_day_s1 = []
volume_day_s2 = []
# needed to convert emoji codes to names
ub = UtilityBoss()
for curr_day in days_of_week:
Expand All @@ -112,6 +114,8 @@ def create_time_trends(tes_list):
link_day_s2.append(day_calcs['link_rate_s2'])
double_day_s1.append(day_calcs['double_text_rate_s1'])
double_day_s2.append(day_calcs['double_text_rate_s2'])
volume_day_s1.append(day_calcs['texts_sent_s1'])
volume_day_s2.append(day_calcs['texts_sent_s2'])
if day_calcs['top_emojis_s1']:
day_s1_emojis = [ub.convert_emoji_code(code) for code in day_calcs['top_emojis_s1']]
top_ems_day_s1.append(day_s1_emojis)
Expand Down Expand Up @@ -142,6 +146,8 @@ def create_time_trends(tes_list):
double_hr_s2 = []
top_ems_hr_s1 = []
top_ems_hr_s2 = []
volume_hr_s1 = []
volume_hr_s2 = []
for curr_hour in hours_of_day:
hour_tes = filter_poly.filter_by_time_of_day([curr_hour],tes_list)['filtered_tes']
hour_calcs = metric_calculations.calculate_all_metrics(hour_tes)
Expand All @@ -157,6 +163,8 @@ def create_time_trends(tes_list):
link_hr_s2.append(hour_calcs['link_rate_s2'])
double_hr_s1.append(hour_calcs['double_text_rate_s1'])
double_hr_s2.append(hour_calcs['double_text_rate_s2'])
volume_hr_s1.append(hour_calcs['texts_sent_s1'])
volume_hr_s2.append(hour_calcs['texts_sent_s2'])
if hour_calcs['top_emojis_s1']:
hr_s1_emojis = [ub.convert_emoji_code(code) for code in hour_calcs['top_emojis_s1']]
top_ems_hr_s1.append(hr_s1_emojis)
Expand All @@ -183,6 +191,7 @@ def create_time_trends(tes_list):
'link_rate':link_hr_s1,
'double_text_rate':double_hr_s1,
'top_emojis':top_ems_hr_s1,
'texts_sent':volume_hr_s1,
'participant': ['Me']*len(hours_of_day) }

hour_d_2 = {'hour_x':hours_of_day,
Expand All @@ -193,14 +202,13 @@ def create_time_trends(tes_list):
'link_rate':link_hr_s2,
'double_text_rate':double_hr_s2,
'top_emojis':top_ems_hr_s2,
'texts_sent':volume_hr_s2,
'participant': ['Friend']*len(hours_of_day)
}
#append the data frames for both participants
df_hour = pd.DataFrame(hour_d_1)
df_hour = df_hour.append(pd.DataFrame(hour_d_2))

print(str(df_hour))

day_d_1 = {
'day_x':day_of_week_words,
'wait_time': wait_day_time_s1,
Expand All @@ -210,6 +218,7 @@ def create_time_trends(tes_list):
'link_rate':link_day_s1,
'double_text_rate':double_day_s1,
'top_emojis':top_ems_day_s1,
'texts_sent':volume_day_s1,
'participant':['Me']*len(day_of_week_words)
}

Expand All @@ -222,12 +231,12 @@ def create_time_trends(tes_list):
'link_rate':link_day_s2,
'double_text_rate':double_day_s2,
'top_emojis':top_ems_day_s2,
'texts_sent':volume_day_s2,
'participant':['Friend']*len(day_of_week_words)
}
#append the data frames for both participants
df_day = pd.DataFrame(day_d_1)
df_day = df_day.append(pd.DataFrame(day_d_2))
print(str(df_day))


return({'hours_df':df_hour,
Expand Down

0 comments on commit 9bf656b

Please sign in to comment.