Price per calorie of various snack foods

Question

Suppose you are given the following dataset containing food, servings per container, calories per serving, and price per container. You'll notice that each food's price, serving size, and servings per container widely varies. Create a sorted list (lowest to highest) with the food and the associated price per calorie. Below is code to generate the dataframe, or you can also make a copy of this Google Colab notebook to get started.

# code to import data
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/erood/interviewqs.com_code_snippets/master/Datasets/snackfood.csv')
# preview data
df.head()

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now