<jupyter_start><jupyter_text>Day<jupyter_code>labelled_app_events.head()
import calendar
sns.set(font_scale=1.3)

labelled_app_events['week_day'] = labelled_app_events.timestamp.apply(lambda x: calendar.day_name[x.weekday()])
plt.figure()
ax = sns.countplot(x="week_day", data=labelled_app_events)
days = np.sort(labelled_app_events['week_day'].unique())
ind = np.arange(len(days))  # the x locations for the groups
width = 0.35

male_days = []
female_days = []
for day in days:
    day_rows = labelled_app_events[ labelled_app_events['week_day'] == day]
    female_days.append(len(day_rows.query('gender == "F"')))
    male_days.append(len(day_rows.query('gender == "M"')))

    plt.figure(figsize=(12,6))

p1 = plt.bar(ind, male_days, width, color="#1292db", label='Men')
p2 = plt.bar(ind, female_days, width, color="#ff69b4", bottom=male_days, label='Women')

plt.ylabel('Count of events',{'fontsize': 20})
plt.xlabel('Day of the week',{'fontsize': 20})
plt.xticks(size=15)
plt.yticks(size=15)
plt.legend((p2[0], p1[0]), ('Women', 'Men'))
ltext = plt.gca().get_legend().get_texts()
plt.setp(ltext[0], fontsize=20)
plt.setp(ltext[1], fontsize=20)
plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
           ncol=2, mode="expand", borderaxespad=0.)
plt.show()
tot = map(add, female_days, male_days)
total = pd.Series(tot, index=range(len(male_days)))
f_users = list(female_days/total)
m_users = list(male_days/total)

f_users = [ '%.3f' % elem for elem in f_users]
m_users = [ '%.3f' % elem for elem in m_users]

print "During the whole day the percentage of users are: "
print "- females: {}\n- males: {}".format(f_users, m_users)
plt.figure()
labelled_app_events['hours'] = labelled_app_events['timestamp'].apply(lambda x: x.hour)
ax = sns.countplot(x='hours', data=labelled_app_events)
hours = np.sort(labelled_app_events['hours'].unique())
ind = np.arange(len(hours))  # the x locations for the groups
width = 0.35

male_hours = []
female_hours = []
for hour in hours:
    hour_rows = labelled_app_events[ labelled_app_events['hours'] == hour]
    female_hours.append(len(hour_rows.query('gender == "F"')))
    male_hours.append(len(hour_rows.query('gender == "M"')))

plt.figure()
p1 = plt.bar(ind, male_hours, width, color="#1292db")
p2 = plt.bar(ind, female_hours, width, color="#ff69b4", bottom=male_hours)
plt.ylabel('Number of events')
plt.title('Hourly breakdown of phone usage between M and F')
plt.legend((p2[0], p1[0]), ('Women', 'Men'))
plt.show()
tot = map(add, female_hours, male_hours)
total = pd.Series(tot, index=range(len(male_hours)))
f_users = list(female_hours/total)
m_users = list(male_hours/total)

f_users = [ '%.3f' % elem for elem in f_users]
m_users = [ '%.3f' % elem for elem in m_users]

print "During the whole day the percentage of users are: "
print "- females: {}\n- males: {}".format(f_users, m_users)
age_h_f = (labelled_app_events[labelled_app_events['gender'] == 'F']
           .groupby(['hours', 'group'])
           .agg('count')
           )
age_h_m = (labelled_app_events[labelled_app_events['gender'] == 'M']
           .groupby(['hours', 'group'])
           .agg('count')
           )
age_h = (labelled_app_events
           .groupby(['hours', 'group'])
           .agg('count')
           )

age_h = age_h['device_id'].reset_index()
groups = age_h.pivot(index='hours', columns='group')

ax = groups.plot(kind='bar', stacked=True, colormap='Paired', rot=0, figsize=(15,6))
plt.legend(bbox_to_anchor=(1., 1), loc=2, borderaxespad=0.)
handles, labels = ax.get_legend_handles_labels()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17970283151107372, 'fraction_numerical': 0.020745724698626296, 'mean_word_length': 5.248686514886165, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '154328', 'license': 'MIT', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1321, 'n_words': 262, 'path': 'notebooks/data_exploration/.ipynb_checkpoints/events_exploration-checkpoint.ipynb', 'repo_name': 'Kebniss/Capstone-project', 'size': '3567'}