Rewrite detrend process
Summary
Rewrite detrend process
What is the current bug behavior?
The detrend process code is difficult to understand, therefore, difficult to maintain and be sure that it does what it should.
Possible fixes
- Lots of 'God lines' in lines 20-24 and 70-77 that are difficult to understand. We should break down the computation process into human-understandable, discrete steps, preferably with comments.
- Use
DataFrame.rolling() - Use standard routines in
numpyandscipy, e.g.numpy.ma.average-- better documented, used by many people, therefore more sure that they're doing the right thing.