<jupyter_start><jupyter_text>Migraine and acupuncture<jupyter_code>import pandas as pd
df = pd.read_csv('Dataset/migraine.csv')
print(df.shape)
df.head()
def counting(x):
    return x.count()
contingency = df.pivot_table(index='group',columns='pain_free',aggfunc=[counting])
contingency
#For some reasons, I got a redundancy when the only column should have been 'pain_free'. to go on with this matter, I deleted the "group" column
del contingency[('counting','group')]
contingency
contingency.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Index: 2 entries, control to treatment
Data columns (total 2 columns):
(counting, pain_free, no)     2 non-null int64
(counting, pain_free, yes)    2 non-null int64
dtypes: int64(2)
memory usage: 40.0+ bytes<jupyter_text>Horizontal Total<jupyter_code>contingency.loc[:,('counting','pain_free','Total')] = contingency.sum(axis=1)
contingency<jupyter_output><empty_output><jupyter_text>Vertical Total<jupyter_code>contingency.loc['Tot'] = contingency.sum()
contingency<jupyter_output><empty_output><jupyter_text>1. What percent of patients in the treatment group were pain free 24 hours after receiving acupuncture ? What percent in the control group ? Percent of patients  who were **pain free** in the **treatment** group :<jupyter_code>print((contingency.loc['treatment',('counting','pain_free','yes')] / contingency.loc['treatment',('counting','pain_free','Total')]) * 100,'%')<jupyter_output>23.2558139535 %<jupyter_text>Percent of patients  who were **pain free** in the **control** group :<jupyter_code>print((contingency.loc['control',('counting','pain_free','yes')] / contingency.loc['control',('counting','pain_free','Total')]) * 100,'%')<jupyter_output>4.34782608696 %
{'fraction_non_alphanumeric': 0.14846909300982092, 'fraction_numerical': 0.02772963604852686, 'mean_word_length': 8.362162162162162, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '134546', 'license': 'MIT', 'n_tokens_mistral': 631, 'n_tokens_neox': 575, 'n_words': 133, 'path': 'Chapter 1/Exercises/exercise_1.ipynb', 'repo_name': 'chikoungoun/OpenIntro', 'size': '1731'}