Tidy Up Author Names
Problem
You are given a DataFrame `author` with columns `author_id` and `pen_name`. Each pen name may be stored with inconsistent capitalisation.
Return each `author_id` together with a tidied `pen_name` where the first letter is uppercase and every following letter is lowercase. Order the result by `author_id`. Output columns: `author_id`, `pen_name`.
Input data
Example rows — the live problem includes the full dataset.
author
| author_id | pen_name |
|---|---|
| 1 | aLICE |
| 2 | BORIS |
| 3 | cora |
Expected output
Your answer should return 3 rows with the columns author_id, pen_name.
Starter code (Pandas (Python))
import pandas as pd
def tidy_author_names(author) -> pd.DataFrame:
# Your code here
return authorSolve 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