Percentage change between the current and the prior element.
s = pd.Series([90, 91, 85]) s 0 90 1 91 2 85 dtype: int64 s.pct_change() 0 NaN 1 0.011111 2 -0.065934 dtype: float64
Here is what the above code is Doing:
1. Create a Series object with three values.
2. Call the pct_change() method on the Series object.
3. The pct_change() method returns a new Series object with the percent change between each value.
The first value in the Series is NaN because there is no previous value to calculate a percent change from.