Challenge

Project 2

import pandas as pd # Step 1: Read the data for white and red wines into separate DataFrames

white_wine_data = pd.read_csv('white_wine_data.csv')

red_wine_data = pd.read_csv('red_wine_data.csv')

print("White Wine Data:")

print(white_wine_data.head())

print("\nRed Wine Data:")

print(red_wine_data.head())

print("Size of White Wine Data:", white_wine_data.shape)

print("Size of Red Wine Data:", red_wine_data.shape)

print("Number of null values in White Wine Data:")

print(white_wine_data.isnull().sum())

print("\nNumber of null values in Red Wine Data:")

print(red_wine_data.isnull().sum())

white_wine_data.drop_duplicates(inplace=True)

red_wine_data.drop_duplicates(inplace=True)

print("Number of unique values in White Wine Data:")

print(white_wine_data.nunique())

print("\nNumber of unique values in Red Wine Data:")

print(red_wine_data.nunique())

print("Mean density of White Wine:",

white_wine_data['density'].mean())

print("Mean density of Red Wine:", red_wine_data['density'].mean())

# Add a 'color' column to each DataFrame to identify the type of wine

white_wine_data['color'] = 'white'

red_wine_data['color'] = 'red' # Concatenate both DataFrames to create a single combined DataFrame

combined_data = pd.concat([white_wine_data, red_wine_data], ignore_index=True)

combined_data.dropna(inplace=True)

# Assuming you have a column named 'alcohol' and 'quality' for ratings

higher_alcohol_ratings = combined_data.groupby('alcohol')['quality'].mean()

print(higher_alcohol_ratings)

correlation = combined_data['citric acid'].corr(combined_data['pH'])

print("Correlation between citric acid content and pH:", correlation)

import statsmodels.api as sm X = combined_data['citric acid']

y = combined_data['pH'] X = sm.add_constant(X)

model = sm.OLS(y, X).fit() print(model.summary())

from statsmodels.stats.proportion

import proportion_confint

white_wine_rating3_prop = combined_data.loc[combined_data['color'] == 'white', 'quality'].value_counts(normalize=True).get(3, 0)

red_wine_rating3_prop = combined_data.loc[combined_data['color'] == 'red', 'quality'].value_counts(normalize=True).get(3, 0)

# Assuming you have enough samples for each group

n_white = len(combined_data.loc[combined_data['color'] == 'white'])

n_red = len(combined_data.loc[combined_data['color'] == 'red']) # Calculate the confidence intervals

ci_white = proportion_confint

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.