import pandas as pd
df= pd.read_csv('wine.csv')
df_new = df.query('fixed_acidity > 7')
df_new.head()
df_new = df.query('color == "red"')
df_new.head()
df_new = df[df['fixed_acidity'] > 7]
df_new.head()
df_new = df[df['color'] == "red"]
df_new.head()
- Calculate median for 'alcohol'
- Low_alcohol -> data with 'alcohol' content less than the median
- High_alcohol -> data with 'alcohol' content greater than or equal to the median
Median = df['alcohol'].median()
Low_alcohol = df[df['alcohol'] < Median]
High_alcohol = df[df['alcohol'] >= Median]
print("Low_alcohol Result:")
Low_alcohol[['alcohol','quality']].mean()
print("High_alcohol Result:")
High_alcohol[['alcohol','quality']].mean()
- Calculate median for 'residual_sugar'
- less_residual:
data with 'residual_sugar' content less than the median
- more_residual:
data with 'residual_sugar' content greater than or equal to the median
Median = df['residual_sugar'].median()
less_residual = df[df['residual_sugar'] < Median]
more_residual = df[df['residual_sugar'] >= Median]
print("Less Residual Result:")
less_residual[['residual_sugar','quality']].mean()
print("More Residual Result:")
more_residual[['residual_sugar','quality']].mean()