This file contains hidden or 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
# code creates a new column based on the quality of the wine using 6 as a threshold | |
df['rating'] = df['quality'].apply(lambda x: 'good' if x >= 6 else 'bad') |
This file contains hidden or 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
# from Udemy course: Data Science & Deep Learning for Business | |
# stratum_white and stratum_red are Data Frames | |
alcohol_per_wine_type = {} | |
for stratum, wine_type in [(stratum_white, 'white'), (stratum_red, 'red')]: | |
sample = stratum['alcohol'].sample(250, random_state = 0) # random sampling on each stratum | |
alcohol_per_wine_type[wine_type] = sample.mean() | |
print(alcohol_per_wine_type) |