This is probably due to my crappy math/pandas skills but i don't understand why i lose rows when i upsample a pandas dataframe. Here is an exmaple:
In:
import numpy as np
import pandas as pd
tester = pd.DataFrame(np.linspace(0, 3, 4))
tester.index = pd.to_datetime(tester.index, unit="s")
print(tester.shape)
tester
Out:
(4, 1)
1970-01-01 00:00:00 0.0
1970-01-01 00:00:01 1.0
1970-01-01 00:00:02 2.0
1970-01-01 00:00:03 3.0
In:
tester2 = tester.resample('0.5S').ffill()
print(tester2.shape)
tester2
Out:
(7, 1)
1970-01-01 00:00:00.000 0.0
1970-01-01 00:00:00.500 0.0
1970-01-01 00:00:01.000 1.0
1970-01-01 00:00:01.500 1.0
1970-01-01 00:00:02.000 2.0
1970-01-01 00:00:02.500 2.0
1970-01-01 00:00:03.000 3.0
This gets worse as I increase the upsampling rate. Is there any way to circumvent the behavior? E.g. if the input is 4 rows then i want to see exactly 8 rows after '0.5S' upsampling.