Binning Ages with pd.cut

easy
Unit 5 · Pandas & Outliers0/3 to milestone

Implement age_bands(ages) that takes a list of ages and returns a pandas Series of string labels using these right-open bands:

"0-17", "18-34", "35-54", "55+"

and band_counts(ages) returning a dict of counts for every band (including zero counts), in band order. Missing ages (None/NaN) get the label "unknown" and are counted under "unknown" only if any exist.

#pandas#binning2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Binning Ages with pd.cut · TechGradify