Pandasdrill

Level 5: Analysis Exercise 38 of 45 Pro

Month over month growth

A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.

The task

Return the month over month change in `revenue` as a fraction (0.25 means 25 percent growth). The first month has no prior month and is NaN.

What this exercise teaches

pct_change computes (current - previous) / previous for every row. diff would give the change in dollars rather than as a fraction.

A hint if you get stuck

pct_change compares each value with the one before it.

This exercise is part of Pro

Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Analysis