Created
January 10, 2018 16:50
-
-
Save dipanjanS/a46164dd85295fc0d7d7e708b3936184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
white_wine = pd.read_csv('winequality-white.csv', sep=';') | |
red_wine = pd.read_csv('winequality-red.csv', sep=';') | |
# store wine type as an attribute | |
red_wine['wine_type'] = 'red' | |
white_wine['wine_type'] = 'white' | |
# bucket wine quality scores into qualitative quality labels | |
red_wine['quality_label'] = red_wine['quality'].apply(lambda value: 'low' | |
if value <= 5 else 'medium' | |
if value <= 7 else 'high') | |
red_wine['quality_label'] = pd.Categorical(red_wine['quality_label'], | |
categories=['low', 'medium', 'high']) | |
white_wine['quality_label'] = white_wine['quality'].apply(lambda value: 'low' | |
if value <= 5 else 'medium' | |
if value <= 7 else 'high') | |
white_wine['quality_label'] = pd.Categorical(white_wine['quality_label'], | |
categories=['low', 'medium', 'high']) | |
# merge red and white wine datasets | |
wines = pd.concat([red_wine, white_wine]) | |
# re-shuffle records just to randomize data points | |
wines = wines.sample(frac=1, random_state=42).reset_index(drop=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment