January 2020
Beginner to intermediate
432 pages
11h 24m
English
Normally, we could use the resample method of a pandas DataFrame. Supposing we wanted to calculate the average monthly return, we could run df.log_rtn.resample('M').mean().
For the resample method, we can use any built-in aggregate functions of pandas, such as mean, sum, min, and max. However, our case is a bit more complex, so we defined a helper function called realized_volatility, and replicated the behavior of resample by using a combination of groupby, Grouper, and apply.
We presented the most basic visualization of the results (please refer to the next recipe for information about visualizing time series).
Read now
Unlock full access