I'm only four years late here and can't comment yet, so adding this as an answer.
It's probably the newer Python & Pandas causing this but this now fires Assertion Error, as the .groupby adds the grouping key to the output.
df["cagr"] = df.groupby("company").apply(lambda x, period: ((x.pct_change(period) + 1) ** (1/period)) - 1, cagr_period)
Simple fix to this is to use group_keys=False
df["cagr"] = df.groupby("company", group_keys=False).apply(lambda x, period: ((x.pct_change(period) + 1) ** (1/period)) - 1, cagr_period)