AnalystPath

Build a Savory-and-Sweet Combo

PandasEasyJunior level~10 min

Problem

You are given a DataFrame `dish` describing a cafe menu. It has columns `dish_name`, `flavor` (one of 'Savory', 'Sweet', or 'Drink'), and `calories`.

A combo deal pairs one savory dish with one sweet dish. List every possible combo: each pairing of a 'Savory' dish with a 'Sweet' dish.

Return two columns, `savory` and `sweet`, holding the two dish names. The result may be returned in any order.

Input data

Example rows — the live problem includes the full dataset.

dish
dish_nameflavorcalories
LatteDrink120
QuicheSavory310
PaniniSavory420
FrittataSavory280
BrownieSweet260

Expected output

Your answer should return 9 rows with the columns savory, sweet.

Starter code (Pandas (Python))

import pandas as pd

def build_savory_sweet_combo(dish) -> pd.DataFrame:
    # Your code here
    return dish

Solve this Pandas question free

Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related Pandas questions