Skip to content

Fix dataframes resampling method

Summary

Resampling logic contains syntax and semantic errors.

When e.g. resampling following dataframe:

2000-01-01 00:00:00   0
2000-01-01 00:00:08   8
2000-01-01 00:00:16  16
2000-01-01 00:00:24  24
2000-01-01 00:00:32  32
2000-01-01 00:00:40  40

with frequency 3 and interpolate inbetween, we get as result: (current behaviour)

2000-01-01 00:00:00   0.0
2000-01-01 00:00:03   3.0
2000-01-01 00:00:06   6.0
2000-01-01 00:00:09   9.0
2000-01-01 00:00:12  12.0
2000-01-01 00:00:15  15.0
2000-01-01 00:00:18  18.0
2000-01-01 00:00:21  21.0
2000-01-01 00:00:24  24.0
2000-01-01 00:00:27  24.0
2000-01-01 00:00:30  24.0
2000-01-01 00:00:33  24.0
2000-01-01 00:00:36  24.0
2000-01-01 00:00:39  24.0

Performing an interpolation after resampling would result in

2000-01-01 00:00:00   0.000000
2000-01-01 00:00:03   4.000000
2000-01-01 00:00:06   8.000000
2000-01-01 00:00:09  10.666667
2000-01-01 00:00:12  13.333333
2000-01-01 00:00:15  16.000000
2000-01-01 00:00:18  18.666667
2000-01-01 00:00:21  21.333333
2000-01-01 00:00:24  24.000000
2000-01-01 00:00:27  28.000000
2000-01-01 00:00:30  32.000000
2000-01-01 00:00:33  34.666667
2000-01-01 00:00:36  37.333333
2000-01-01 00:00:39  40.000000

But we want this:

2000-01-01 00:00:00   0.0
2000-01-01 00:00:03   3.0
2000-01-01 00:00:06   6.0
2000-01-01 00:00:09   9.0
2000-01-01 00:00:12  12.0
2000-01-01 00:00:15  15.0
2000-01-01 00:00:18  18.0
2000-01-01 00:00:21  21.0
2000-01-01 00:00:24  24.0
2000-01-01 00:00:27  27.0
2000-01-01 00:00:30  30.0
2000-01-01 00:00:33  33.0
2000-01-01 00:00:36  36.0
2000-01-01 00:00:39  39.0

Explain your context

(Explain what you did.)

What is the expected correct behavior? What was your goal?

(What you should see instead.)

What is the current bug behavior?

(What actually happens.)

Was there an error message?

(Paste any relevant logs - please use

code blocks like this one

or

this one

to format console output, logs, and code, as it's very hard to read otherwise.)

Steps to reproduce

(How one can reproduce the issue - this is very important)

Edited by Julius Balzer