defbreak_down_series(series):"""Return value counts, proportions and percentages of a pandas series"""counts=series.value_counts()props=series.value_counts(normalize=True).round(2)percentages=props.mul(100).round(2).astype(str)+"%"returnpd.DataFrame({"count":counts,"proportion":props,"percentage":percentages})
Note: this type of breakdown of a series' values makes more sense for categorical/discrete data. For continuous/numeric data, it’s better to use pandas.Series.describe()
which returns descriptive statistics, including 25th, 50th, and 75th percentiles.