<jupyter_start><jupyter_text>Drawing Conclusions Using Query<jupyter_code># Load 'winequality_edited.csv,' a file you previously created
# in this workspace and worked with in the concepts
# "Appending Data(cont.)" and "Exploring with Visuals"
import pandas as pd
df = pd.read_csv('winequality_edited.csv')
df.head()<jupyter_output><empty_output><jupyter_text>Do wines with higher alcoholic content receive better ratings?<jupyter_code># get the median amount of alcohol content
df.median().alcohol
# select samples with alcohol content less than the median
low_alcohol = df.query('alcohol < 10.300000000000001')

# select samples with alcohol content greater than or equal to the median
high_alcohol = df.query('alcohol >=  10.300000000000001')

# ensure these queries included each sample exactly once
num_samples = df.shape[0]
num_samples == low_alcohol['quality'].count() + high_alcohol['quality'].count() # should be True
# get mean quality rating for the low alcohol and high alcohol groups
low_alcohol.mean().quality, high_alcohol.mean().quality<jupyter_output><empty_output><jupyter_text>Do sweeter wines receive better ratings?<jupyter_code># get the median amount of residual sugar
df.median().residual_sugar
# select samples with residual sugar less than the median
low_sugar = df.query('residual_sugar < 3.0')

# select samples with residual sugar greater than or equal to the median
high_sugar = df.query('residual_sugar >= 3.0')

# ensure these queries included each sample exactly once
num_samples == low_sugar['quality'].count() + high_sugar['quality'].count() # should be True
# get mean quality rating for the low sugar and high sugar groups
low_sugar.mean().quality, high_sugar.mean().quality<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09304997128087306, 'fraction_numerical': 0.022400919012062034, 'mean_word_length': 6.412765957446808, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '516982', 'license': 'Apache-2.0', 'n_tokens_mistral': 547, 'n_tokens_neox': 498, 'n_words': 174, 'path': '2_Intro_to_data_analysis/Data_Analysis_Case_study_1/Quizes/conclusions_query.ipynb', 'repo_name': 'sudoberlin/Data_Analyst_ND', 'size': '1741'}