Title-Case Recipe Names With Hyphens
Problem
A recipe site stores names in inconsistent casing inside the `recipe_titles` DataFrame. Convert each `raw_title` to title case: the first letter of every word becomes uppercase and the remaining letters of the word become lowercase. A word may contain hyphens, and each hyphen-separated part must also be capitalized — for example `slow-cooked` becomes `Slow-Cooked`. Spaces, hyphens, and all other characters stay exactly where they are. Return `recipe_id`, the unchanged title as `original_title`, and the converted text as `title_cased`, ordered by `recipe_id`.
Input data
Example rows — the live problem includes the full dataset.
| recipe_id | raw_title |
|---|---|
| 1 | creamy tomato BASIL soup |
| 2 | the SLOW-cooked stew |
| 3 | pan-seared SALMON fillet |
| 4 | oven-baked SWEET-potato wedges |
Expected output
Your answer should return 4 rows with the columns recipe_id, original_title, title_cased.
Starter code (Pandas (Python))
import pandas as pd
def title_case_recipe_names(recipe_titles) -> pd.DataFrame:
# Your code here
return recipe_titlesSolve 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