Skip to content

Instantly share code, notes, and snippets.

@MarkusMueller-DS
Last active October 2, 2020 07:55
Show Gist options
  • Save MarkusMueller-DS/8f56433b3fd64ba68de0dbf690202a6c to your computer and use it in GitHub Desktop.
Save MarkusMueller-DS/8f56433b3fd64ba68de0dbf690202a6c to your computer and use it in GitHub Desktop.
a for loop which saves the result of a sampling dist in a dict
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment