<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 JuxtBoard User Study
Imports
Step1:  Helper Functions
Step2:  Load Excel
Step3:  Basic Data
Step4:  Age
Step5:  Genre
Step6:  Education
Step7:  Type of Devices
Step8:  Percentage of Users that User Multiple Devices Sometimes or More Often
Step9:  Test Mode
Step10:  SUS - Single Device Mode
Questions
I think that I would like to use this system frequently.
I found the system unnecessarily complex.
I thought the system was easy to use.
I think that I would need the support of a technical person to be able to use this system.
I found the various functions in this system were well integrated.
I thought there was too much inconsistency in this system.
I would imagine that most people would learn to use this system very quickly.
I found the system very cumbersome to use.
I felt very confident using the system.
I needed to learn a lot of things before I could get going with this system.
Step11:  Mean Score 100
Step12:  General Stats
Step13:  Confidence Interval
Step14:  Per-question Stats
Step15:  SUS - Multi-Device Mode
Questions
I think that I would like to use this system frequently.
I found the system unnecessarily complex.
I thought the system was easy to use.
I think that I would need the support of a technical person to be able to use this system.
I found the various functions in this system were well integrated.
I thought there was too much inconsistency in this system.
I would imagine that most people would learn to use this system very quickly.
I found the system very cumbersome to use.
I felt very confident using the system.
I needed to learn a lot of things before I could get going with this system.
Step16:  Mean Score 100
Step17:  General Stats
Step18:  Confidence Interval
Step19:  Per-question Stats
Step20:  SUS Single Device vs. SUS Multi-Device
Dependent t-test for paired samples
Step21:  Single Device vs. SUS Multi-Device
Questions (Portuguese)
Em que modo de utilização foi mais fácil manipular as colecções de notas na aplicação (por exemplo, seleccioná-las, adicioná-las, partilhá-las, renomeá-las ou removê-las).
Em que modo de utilização foi mais fácil gerir as notas na aplicação (por exemplo, seleccioná-las, visualizá-las, adicioná-las, renomeá-las ou removê-las).
Em que modo de utilização foi mais fácil colaborar e mostrar notas aos outros participantes?
Indique o grau de preferência entre os dois modos de interacção do JuxtBoard caso esteja a utilizar a aplicação para realizar uma tarefa sozinho.
Indique o grau de preferência entre os dois modos de interacção do JuxtBoard caso se encontre numa situação em que esteja a utilizar a aplicação e haja necessidade de colaborar com outros utilizadores.
Step22:  Confidence Intervals
Step23:  Response Frequency
Step24:  General Use
Questions (Portuguese)
Normalmente, eu utilizo dois ou mais dispositivos em simultâneo no meu quotidiano.
O tempo que a aplicação demorou a reagir ao meu "input" foi adequado. 
A distância é uma boa medida do quão relacionados são dois dispositivos.
O tempo que o sistema demorou a reagir às alterações nas posições dos dispositivos foi adequado.
É fácil mudar a distribuição dos componentes da interface de acordo com as minhas necessidades.
Eu considero que a distribuição automática dos componentes da interface foi adequada.
Step25:  Confidence Intervals
Step26:  Response Frequency
Step27:  Yanux Calculator
Load Excel
Step28:  Age
Step29:  Genre
Step30:  Education
Step31:  Type of Devices
Step32:  SUS
Questions
I think that I would like to use this system frequently.
I found the system unnecessarily complex.
I thought the system was easy to use.
I think that I would need the support of a technical person to be able to use this system.
I found the various functions in this system were well integrated.
I thought there was too much inconsistency in this system.
I would imagine that most people would learn to use this system very quickly.
I found the system very cumbersome to use.
I felt very confident using the system.
I needed to learn a lot of things before I could get going with this system.
Step33:  Mean Score 100
Step34:  General Stats
Step35:  Confidence Interval
Step36:  Per-question Stats
Step37:  Domain Specific Questions
Step38:  Response Frequency
Step39:  Percentage of Users that User Multiple Devices Sometimes or More Often
<ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy import stats
import statsmodels.stats.proportion as smp
import pandas as pd
import matplotlib.pyplot as plt
Explanation: JuxtBoard User Study
Imports
End of explanation
def print_stats(data, hist_bins=10, hist_size=(8,4)):
    print('--- Statistics ----')
    display(data.describe())
    print('\n')
    print('--- Counting Unique Values ----')
    display(data.value_counts())
    print('\n')
    print('--- Basic Histogram ----')
    data.hist(bins=hist_bins, figsize=hist_size)
    plt.show()
    
def calculate_sus(data):
    for i in range(len(data.columns)):
        if i % 2:
            data.iloc[:,i] = 7 - data.iloc[:,i]
        else:
            data.iloc[:,i] = data.iloc[:,i] - 1
    data['Score'] = data.iloc[:,0:10].sum(axis=1)
    data['Score 100'] = data['Score'] * (100/60)
    return data
def confidence_interval_t(data, confidence_level=0.95):
    return stats.t.interval(confidence_level, data.count()-1, data.mean(), data.sem())
    
Explanation: Helper Functions
End of explanation
data = pd.read_excel('data/userstudies/juxtboard-questionnaire-responses.xlsx', sheet_name=None)  
Explanation: Load Excel
End of explanation
data_basic = data['Basic']
# Translating Genre from Portuguese to English
data_basic['Genre'].replace('Masculino','Male',inplace=True)
data_basic['Genre'].replace('Feminino','Female',inplace=True)
data_basic['Genre'].replace('Prefiro não responder','Prefer not to say',inplace=True)
# Translating Education from Portuguese to English
data_basic['Education'].replace('Educação Básica','Basic Education',inplace=True)
data_basic['Education'].replace('Educação Secundária','Secondary Education',inplace=True)
data_basic['Education'].replace('Educação Pós-Secundária','Post-Secondary Education',inplace=True)
data_basic['Education'].replace('Educação Pós-Secundária','Post-Secondary Education',inplace=True)
data_basic['Education'].replace('Licenciatura','Bachelor\'s Degree',inplace=True)
data_basic['Education'].replace('Mestrado','Master\'s Degree',inplace=True)
data_basic['Education'].replace('Doutoramento','Doctoral Degree',inplace=True)
data_basic['Education'].replace('Prefiro não responder','Prefer not to say',inplace=True)
# Translating Type of Devices from Portuguese to English
data_basic['Type of Devices'].replace({'Computador de secretária':'Desktop'}, regex=True ,inplace=True)
data_basic['Type of Devices'].replace({'Computador portátil':'Laptop'}, regex=True, inplace=True)
# Translating Test mode from Portuguese to English
data_basic['Test Mode'].replace('PRIMEIRO em modo "Multi-Dispositivo" e DEPOIS em modo "Dispositivo Único".','Single Device > Multi-Device',inplace=True)
data_basic['Test Mode'].replace('PRIMEIRO em modo "Dispositivo Único" e DEPOIS em modo "Multi-Disposito".','Multi-Device > Single Device',inplace=True)
#display(data_basic)
Explanation: Basic Data
End of explanation
data_basic_age = data_basic['Age']
print_stats(data_basic_age, hist_bins=20)
print('Population Standard Deviation:')
print(data_basic_age.std(ddof=0))
Explanation: Age
End of explanation
data_basic_genre = data_basic['Genre']
print_stats(data_basic_genre)
Explanation: Genre
End of explanation
data_basic_education = data_basic['Education']
print_stats(data_basic_education)
Explanation: Education
End of explanation
data_basic_type_of_devices = data_basic['Type of Devices'].map(lambda x: [i.strip() for i in x.split(",")])
print('--- Statistics ----')
display(data_basic_type_of_devices.describe())
#print('--- Basic Histogram ----')
#data_basic_type_of_devices.hist()
data_number_of_devices = data_basic_type_of_devices.apply(len)
print_stats(data_number_of_devices)
#print('Population Standard Deviation:')
#print(data_number_of_devices.std(ddof=0))
data_basic_usage_multiple_devices = data_basic['Usage of Multiple-Devices']
print_stats(data_basic_usage_multiple_devices)
#print('Population Standard Deviation:')
#print(data_basic_usage_multiple_devices.std(ddof=0))
Explanation: Type of Devices
End of explanation
(data_basic_usage_multiple_devices[data_basic_usage_multiple_devices >= 5].count()/data_basic_usage_multiple_devices.count())*100
Explanation: Percentage of Users that User Multiple Devices Sometimes or More Often
End of explanation
data_basic_test_mode = data_basic['Test Mode']
print_stats(data_basic_test_mode)
Explanation: Test Mode
End of explanation
data_sus_single_device = calculate_sus(data['SUS Single Device'].copy().dropna())
#data_sus_single_device
Explanation: SUS - Single Device Mode
Questions
I think that I would like to use this system frequently.
I found the system unnecessarily complex.
I thought the system was easy to use.
I think that I would need the support of a technical person to be able to use this system.
I found the various functions in this system were well integrated.
I thought there was too much inconsistency in this system.
I would imagine that most people would learn to use this system very quickly.
I found the system very cumbersome to use.
I felt very confident using the system.
I needed to learn a lot of things before I could get going with this system.
End of explanation
print(data_sus_single_device['Score 100'].mean())
Explanation: Mean Score 100
End of explanation
data_sus_single_device.describe()
#print_stats(data_sus_single_device)
Explanation: General Stats
End of explanation
confidence_interval_t(data_sus_single_device['Score 100'])
Explanation: Confidence Interval
End of explanation
##Uncomment if you need these stats
#for column in data_sus_single_device:
    #print_stats(data_sus_single_device[column])
Explanation: Per-question Stats
End of explanation
data_sus_multi_device = calculate_sus(data['SUS Multi-Device'].copy().dropna())
#data_sus_multi_device
Explanation: SUS - Multi-Device Mode
Questions
I think that I would like to use this system frequently.
I found the system unnecessarily complex.
I thought the system was easy to use.
I think that I would need the support of a technical person to be able to use this system.
I found the various functions in this system were well integrated.
I thought there was too much inconsistency in this system.
I would imagine that most people would learn to use this system very quickly.
I found the system very cumbersome to use.
I felt very confident using the system.
I needed to learn a lot of things before I could get going with this system.
End of explanation
print(data_sus_multi_device['Score 100'].mean())
Explanation: Mean Score 100
End of explanation
data_sus_multi_device.describe()
#print_stats(data_sus_multi_device)
Explanation: General Stats
End of explanation
confidence_interval_t(data_sus_multi_device['Score 100'])
Explanation: Confidence Interval
End of explanation
##Uncomment if you need these stats
#for column in data_sus_multi_device:
    #print_stats(data_sus_multi_device[column])
Explanation: Per-question Stats
End of explanation
stats.ttest_rel(data_sus_multi_device['Score 100'], data_sus_single_device['Score 100'])
Explanation: SUS Single Device vs. SUS Multi-Device
Dependent t-test for paired samples
End of explanation
data_sd_md = data['SD vs. MD'].copy().dropna()
data_sd_md.iloc[:,0:5] = data_sd_md.iloc[:,0:5] - 4
#data_sd_md
print_stats(data_sd_md, hist_size=(10,8))
Explanation: Single Device vs. SUS Multi-Device
Questions (Portuguese)
Em que modo de utilização foi mais fácil manipular as colecções de notas na aplicação (por exemplo, seleccioná-las, adicioná-las, partilhá-las, renomeá-las ou removê-las).
Em que modo de utilização foi mais fácil gerir as notas na aplicação (por exemplo, seleccioná-las, visualizá-las, adicioná-las, renomeá-las ou removê-las).
Em que modo de utilização foi mais fácil colaborar e mostrar notas aos outros participantes?
Indique o grau de preferência entre os dois modos de interacção do JuxtBoard caso esteja a utilizar a aplicação para realizar uma tarefa sozinho.
Indique o grau de preferência entre os dois modos de interacção do JuxtBoard caso se encontre numa situação em que esteja a utilizar a aplicação e haja necessidade de colaborar com outros utilizadores.
End of explanation
for question in data_sd_md:
    print(question, 
          'Median:', data_sd_md[question].median(), 
          'Mean:', data_sd_md[question].mean(),
          'Standard Deviation:', data_sd_md[question].std(),
          'Confidence Interval:', confidence_interval_t(data_sd_md[question]))
Explanation: Confidence Intervals
End of explanation
data_sd_md_freq = data['SD vs. MD'].copy().dropna()
data_sd_md_freq.iloc[:,0:5] = data_sd_md_freq.iloc[:,0:5] - 4
data_sd_md_freq_res = (data_sd_md_freq.apply(pd.value_counts).fillna(0)/data_sd_md_freq.count()*100).transpose()
data_sd_md_freq_res
data_sd_md_freq_res.to_csv('out/juxtboard-data_sd_md_freq_res.csv')
data_sd_md_freq.describe()
data_sd_md_freq_res.iloc[::-1].plot.barh(stacked=True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
# Multi-Device Preference vs. Neutrality + Single Device Preference
data_sd_md_md_pref = (data_sd_md > 0).sum()
data_sd_md_neutral_or_sd_pre = (data_sd_md <= 0).sum()
data_sd_md_md_pref_relative = data_sd_md_md_pref / (data_sd_md_md_pref + data_sd_md_neutral_or_sd_pre)
# Single Device Preference vs. Neutrality + Multi-Device Preference
data_sd_md_sd_pref = (data_sd_md < 0).sum()
data_sd_md_neutral_or_md_pre = (data_sd_md <= 0).sum()
data_sd_md_sd_pref_relative = data_sd_md_sd_pref / (data_sd_md_sd_pref + data_sd_md_neutral_or_md_pre)
print('Multi-Device Preference vs. Neutrality + Single Device Preference')
for question in data_sd_md:
    print(question, 
          'Relative Frequency:',
          data_sd_md_md_pref_relative[question], 
          'Confidence Interval:',
          smp.proportion_confint(data_sd_md_md_pref[question], data_sd_md_md_pref[question]+data_sd_md_neutral_or_sd_pre[question], alpha=0.05, method='wilson'))
print('\n')
print('Single Device Preference vs. Neutrality + Multi-Device Preference')
for question in data_sd_md:
    print(question,
          'Relative Frequency:',
          data_sd_md_sd_pref_relative[question],
          'Confidence Interval:',
          smp.proportion_confint(data_sd_md_sd_pref[question], data_sd_md_sd_pref[question]+data_sd_md_neutral_or_md_pre[question], alpha=0.05, method='wilson'))
Explanation: Response Frequency
End of explanation
data_general_use = data['General Use'].copy().dropna()
data_general_use['Score'] = data_general_use.iloc[:,0:5].sum(axis=1)
data_general_use['Score 100'] = data_general_use['Score'] * (100/35)
#data_general_use
print_stats(data_general_use, hist_size=(10,8))
Explanation: General Use
Questions (Portuguese)
Normalmente, eu utilizo dois ou mais dispositivos em simultâneo no meu quotidiano.
O tempo que a aplicação demorou a reagir ao meu "input" foi adequado. 
A distância é uma boa medida do quão relacionados são dois dispositivos.
O tempo que o sistema demorou a reagir às alterações nas posições dos dispositivos foi adequado.
É fácil mudar a distribuição dos componentes da interface de acordo com as minhas necessidades.
Eu considero que a distribuição automática dos componentes da interface foi adequada.
End of explanation
for column in data_general_use:
    print(column,
          'Median', data_general_use[column].median(),
          'Mean', data_general_use[column].mean(),
          'Standard Deviation',  data_general_use[column].std(), 
          'Confidence Interval', confidence_interval_t(data_general_use[column]))
Explanation: Confidence Intervals
End of explanation
data_general_use_freq = pd.concat([data_basic['Usage of Multiple-Devices'], data['General Use']], axis=1)
data_general_use_freq = data_general_use_freq.rename(columns={"Usage of Multiple-Devices": "GU0"})
data_general_use_freq_res = (data_general_use_freq.apply(pd.value_counts).fillna(0)/data_general_use_freq.count()*100).transpose()
data_general_use_freq_res
data_general_use_freq.to_csv('out/juxtboard-data_general_use_freq.csv')
data_general_use_freq.describe()
data_general_use_freq_res.iloc[::-1].plot.barh(stacked=True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
Explanation: Response Frequency
End of explanation
data_yxc = pd.read_excel('data/userstudies/yanux-calculator-questionnaire-responses.xlsx', sheet_name=None)  
data_yxc_basic = data['Basic']
#display(data_yxc_basic)
Explanation: Yanux Calculator
Load Excel
End of explanation
data_yxc_basic_age = data_yxc_basic['Age']
print_stats(data_yxc_basic_age, hist_bins=20)
print('Population Standard Deviation:')
print(data_yxc_basic_age.std(ddof=0))
Explanation: Age
End of explanation
data_yxc_basic_genre = data_yxc_basic['Genre']
print_stats(data_yxc_basic_genre)
Explanation: Genre
End of explanation
data_yxc_basic_education = data_yxc_basic['Education']
print_stats(data_yxc_basic_education)
Explanation: Education
End of explanation
data_yxc_basic_type_of_devices = data_yxc_basic['Type of Devices'].map(lambda x: [i.strip() for i in x.split(",")])
print('--- Statistics ----')
display(data_yxc_basic_type_of_devices.describe())
#print('--- Basic Histogram ----')
#data_yxc_basic_type_of_devices.hist()
data_yxc_number_of_devices = data_yxc_basic_type_of_devices.apply(len)
print_stats(data_yxc_number_of_devices)
data_yxc_basic_multiple_devices = data_yxc_basic['Number of Devices']
print_stats(data_yxc_basic_multiple_devices)
print('Population Standard Deviation:')
print(data_yxc_basic_multiple_devices.std(ddof=0))
Explanation: Type of Devices
End of explanation
data_yxc_sus = calculate_sus(data_yxc['SUS'].copy().dropna())
data_yxc_sus
Explanation: SUS
Questions
I think that I would like to use this system frequently.
I found the system unnecessarily complex.
I thought the system was easy to use.
I think that I would need the support of a technical person to be able to use this system.
I found the various functions in this system were well integrated.
I thought there was too much inconsistency in this system.
I would imagine that most people would learn to use this system very quickly.
I found the system very cumbersome to use.
I felt very confident using the system.
I needed to learn a lot of things before I could get going with this system.
End of explanation
print(data_yxc_sus['Score 100'].mean())
Explanation: Mean Score 100
End of explanation
data_yxc_sus.describe()
#print_stats(data_yxc_sus)
Explanation: General Stats
End of explanation
confidence_interval_t(data_yxc_sus['Score 100'])
Explanation: Confidence Interval
End of explanation
##Uncomment if you need these stats
#for column in data_yxc_sus:
    #print_stats(data_yxc_sus[column])
Explanation: Per-question Stats
End of explanation
data_yxc_domain_specific = data_yxc['Domain Specific']
#data_yxc_domain_specific
print_stats(data_yxc_domain_specific)
Explanation: Domain Specific Questions
End of explanation
data_yxc_domain_specific_freq_res = (data_yxc_domain_specific.apply(pd.value_counts).fillna(0)/data_yxc_domain_specific.count()*100).transpose()
data_yxc_domain_specific_freq_res
data_yxc_domain_specific_freq_res.iloc[::-1].plot.barh(stacked=True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
for question in data_yxc_domain_specific:
    print(question,
          'Median:', data_yxc_domain_specific[question].median(), 
          'Mean:', data_yxc_domain_specific[question].mean(), 
          'Standard Deviation:', data_yxc_domain_specific[question].std(), 
          'Confidence Interval:', confidence_interval_t(data_yxc_domain_specific[question]))
Explanation: Response Frequency
End of explanation
data_yxc_basic_usage_multiple_devices = data_yxc_domain_specific['DS1']
(data_yxc_basic_usage_multiple_devices[data_yxc_basic_usage_multiple_devices >= 5].count()/data_yxc_basic_usage_multiple_devices.count())*100
Explanation: Percentage of Users that User Multiple Devices Sometimes or More Often
End of explanation
<END_TASK>