Data-Driven Cocktail Challenge

Use your data science skills to make a delicious beverage

Photo by Sara Cervera on Unsplash

Ready for a refresher on your pandas skills — or just ready for a refreshing drink?

Pandas, the widely used Python library for data analysis and data wrangling, has an incredible variety of useful functions. If you’re new to pandas or just want to practice, this Data-Driven Cocktail Challenge will help you gain familiarity with indexing, utility functions, string functions, and more.

Be sure to refer to the pandas documentation for help if you need it, and, of course, Google and Stack Overflow are your friends, too.

If you want to be extra Pythonic, try to solve each step in just one line of code.

To complete the challenge, check out the image below and complete the blanks in the recipe. It’s like Mad Libs (but with a drink!).

Fill out this recipe as you work through the steps below.

If you’d rather start with a Jupyter Notebook and also see the answers in one, grab them from Github.

Making Your Data-Driven Cocktail

Step 1a
Find the cocktail in the dataset that includes raspberry vodka as its first ingredient. What is the measurement for that first ingredient?

Step 1b
Only one drink contains apricot brandy as its first ingredient and apple brandy as its second. What’s the quantity for apricot brandy?

Step 1c
Only one drink is served in a highball glass and has sugar as its first ingredient. What’s the quantity for sugar?

Step 1d
Only one drink is served in a punch bowl (as its “glass”) and has “apple” in its name. What’s the measurement for its first ingredient?

Step 2a
First ingredient: Find the drink at index 462. What is its second ingredient?

Step 2b
Second ingredient: Find the size of the cocktail dataframe. Divide the size by 93 and round the result to 0 decimal places. Find the cocktail at that index in the dataframe. What is its first ingredient?

Step 2c
Third ingredient: How many drinks in the dataset are listed as “Alcoholic”?
Find that number and subtract 29. Then identify the drink at that index in the dataset and find its fourth ingredient.

Step 2d
Fourth ingredient: Three drinks have names 13 characters long that contain the word “Amaretto.” Find the third ingredient of the drink whose name is second alphabetically among those three drinks.

Step 2e
Fifth ingredient: How many unique values are there for the first measurement column? Find the drink at the index for that value. Identify its third ingredient. You will need a slice of that ingredient as your final item for the recipe.

Step 3
Shake or stir? How many drinks contain “stir” in their instructions? Be sure your query is not case sensitive. If the number is less than 200, use “shake” in your recipe; if 200 or more, use “stir” in the recipe.

Step 4
Which kind of glass should this drink use? Find the memory in bytes used by the names of the drinks (‘strDrink’ column). What is the third digit of the resulting number? Find the drink at that index; put the same kind of glass it uses into your recipe’s instructions.

When you think you’ve got the answers, check out this PDF to see how you did, and refer to the completed Jupyter Notebook for one solution!

An Alteryx Option

And, a bonus: If you’re an Alteryx user, we’re featuring a two-part Weekly Challenge that will guide you through this same challenge with different steps. That version of this challenge will introduce you to some of the Alteryx predictive modeling and statistical analysis tools, too! Check it out on the Alteryx Community.

Data Science Refreshment

If you enjoyed having a little fun with data science, you might also like the new Data Science Mixer podcast, best consumed with a happy hour drink and snack. Check out the show and be sure to subscribe through your favorite podcast player or the Alteryx Community!

Check out all the episodes with this playlist!

The Startup

Get smarter at building your thing. Join The Startup’s +793K followers.

By The Startup

Get smarter at building your thing. Subscribe to receive The Startup's top 10 most read stories — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +793K followers.

Susan Currie Sivek, Ph.D.

Written by

Data Science Journalist, Alteryx. Host, Data Science Mixer podcast. Data geek and former journalism professor and researcher. Writer, knitter, hiker. she/her

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +793K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store