<jupyter_start><jupyter_text>Load dataframe processed in process_protograph_data.ipynb<jupyter_code>dfl = pd.read_csv('csv_dump/processed_study_results.csv').drop(columns=['Unnamed: 0'])<jupyter_output><empty_output><jupyter_text>Plot time distribution as a function of education, experience, and familiarity<jupyter_code>group = list(set(dfl.columns).difference(set(['property','value', 'task name', 'section name', 'variable'])))
print(f'grouping data by: {group}')
data = dfl.groupby(group).mean().reset_index()
plot_by = ['education', 'familiarity', 'experience']
fig, axes = plt.subplots(nrows=1, ncols=len(plot_by), figsize=(14,4))

for (x_label, ax) in zip(plot_by, axes):
    ax = sns.swarmplot(x=x_label, y='duration', ax=ax, data=data)
    ax.set_ylabel('duration (minutes)')
    ax.set_title(f'duration by {x_label}')<jupyter_output><empty_output><jupyter_text>Average scores shown by education, experience, and familiarity<jupyter_code>group = list(set(dfl.columns).difference(set(['property','value', 'task name', 'section name', 'variable'])))
print(f'grouping data by: {group}')
data = dfl.groupby(group).mean().reset_index().drop(columns=['duration'])
#### choose plot function

plot_fnc = sns.barplot
# plot_fnc = sns.swarmplot
# plot_fnc = sns.violinplot

#### Education

order = ['0: other', '1: high-school', '2: bachelors', '3: masters', '4: phd']
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
ax = plot_fnc(x='education', y='value', order=order, data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by education')
plt.show()

display(data.groupby(['education']).describe().drop(columns=['familiarity','experience']).reset_index())

#### Familiarity

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
ax = plot_fnc(x='familiarity', y='value', data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by familiarity with graphs')
plt.show()

display(data.groupby(['familiarity']).describe().drop(columns=['experience']))

#### Experience

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
ax = plot_fnc(x='experience', y='value', data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by experience with coding')
plt.show()

display(data.groupby(['experience']).describe().drop(columns=['familiarity']))<jupyter_output><empty_output><jupyter_text>section scores shown by education, experience, and familiarity<jupyter_code>group = list(set(dfl.columns).difference(set(['property','value', 'task name', 'variable'])))
print(f'grouping data by: {group}')
data = dfl.groupby(group).mean().reset_index().drop(columns=['duration'])
#### choose plot function

plot_fnc = sns.barplot
# plot_fnc = sns.swarmplot
# plot_fnc = sns.violinplot

#### Education

order = ['0: other', '1: high-school', '2: bachelors', '3: masters', '4: phd']
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
ax = plot_fnc(x='education', y='value', hue='section name', order=order, data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by education')
plt.show()

display(data.groupby(['education', 'section name']).describe().drop(columns=['familiarity','experience']).reset_index())

#### Familiarity

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
ax = plot_fnc(x='familiarity', y='value', hue='section name', data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by familiarity with graphs')
plt.show()

display(data.groupby(['familiarity', 'section name']).describe().drop(columns=['experience']))

#### Experience

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
ax = plot_fnc(x='experience', y='value', hue='section name', data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by experience with coding')
plt.show()

display(data.groupby(['experience', 'section name']).describe().drop(columns=['familiarity']))<jupyter_output><empty_output><jupyter_text>task scores shown by education, experience, and familiarity<jupyter_code>group = list(set(dfl.columns).difference(set(['property','value', 'variable'])))
print(f'grouping data by: {group}')
data = dfl.groupby(group).mean().reset_index().drop(columns=['duration'])
#### choose plot function

plot_fnc = sns.barplot
# plot_fnc = sns.swarmplot
# plot_fnc = sns.violinplot

#### Education

order = ['0: other', '1: high-school', '2: bachelors', '3: masters', '4: phd']
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(16,6))
ax = plot_fnc(x='education', y='value', hue='task name', order=order, data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by education')
plt.show()

display(data.groupby(['education', 'task name']).describe().drop(columns=['familiarity','experience']))

#### Familiarity

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(16,6))
ax = plot_fnc(x='familiarity', y='value', hue='task name', data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by familiarity with graphs')
plt.show()

display(data.groupby(['familiarity', 'task name']).describe().drop(columns=['experience']))

#### Experience

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(16,6))
ax = plot_fnc(x='experience', y='value', hue='task name', data=data, ax=ax)
ax.set_ylabel('average score')
ax.set_title('total average score by experience with coding')
plt.show()

display(data.groupby(['experience', 'task name']).describe().drop(columns=['familiarity']))<jupyter_output><empty_output><jupyter_text>look at docs events (in progress)<jupyter_code>df = pd.read_csv('csv_dump/study_docs_events.csv').drop(columns=['Unnamed: 0'])
df = df[df['study_id'].isin(dfl['db_id'])].copy()
df.groupby(['location']).count()<jupyter_output><empty_output><jupyter_text>lines of code in writing tasks<jupyter_code>def count_lines(s):
    # remove blank spaces
    s = s.replace(' ', '')
    # return # of lines with content
    return len([line for line in s.split('\n') if len(line)>0])
survey = pd.read_csv('csv_dump/study_survey_questions.csv').drop(columns=['Unnamed: 0'])
survey = survey[survey['study_id'].isin(dfl['db_id'])].sort_values('study_id').copy()
# get all writing tasks into a single frame
dfs = []
for taskn in [1,2,3]:
    df = pd.read_csv(f'csv_dump/study_part1_task{taskn}.csv').drop(columns=['Unnamed: 0'])
    df['task name'] = f'writing task {taskn}'
    # remove entries not in the final study
    df = df[df['study_id'].isin(dfl['db_id'])].sort_values('study_id').copy()
    assert all(df['study_id'].values == survey['study_id'].values)
    df['eductation'] = survey['education']
    df['familiarity'] = survey['familiarity']
    df['experience'] = survey['experience']
    dfs.append(df)
    

df = pd.concat(dfs)
df['line count'] = df['code'].apply(count_lines)
df.groupby(['task name', 'experience']).describe()
fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(16,6))

sns.barplot(x='task name', y='line count', ax=ax1, data=df)
sns.barplot(x='task name', y='line count', hue='experience', ax=ax2, data=df)
sns.barplot(x='task name', y='line count', hue='familiarity', ax=ax3, data=df)

df.to_csv('csv_dump/writing_line_count.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1942515967786726, 'fraction_numerical': 0.010830324909747292, 'mean_word_length': 7.636690647482014, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 30, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '36845', 'license': 'MIT', 'n_tokens_mistral': 2671, 'n_tokens_neox': 2567, 'n_words': 499, 'path': 'analysis/analyze_protograph_data.ipynb', 'repo_name': 'protograph-io/protograph-system', 'size': '7202'}