I have a dataframe of boolean variables, idexed by timestamps. The timestamps are irregular and I wish to fill in the gaps. I know that the frequency needed is 3ms.
So far, I can do the following :
df = pd.read_csv(path, sep= ';')
df['timestamp'] = pd.to_datetime(df ['timestamp'], errors='raise',infer_datetime_format = True)
df = df.sort(['timestamp'])
df = df.set_index('timestamp')
df.reindex(pd.period_range(df.index[0], df.index[-1], freq='ms'))
df = df.fillna(method = 'ffill')
So, I am reindexing using a ms interval and filling forward missing values (which is what fits my case : all variables are boolean, so at each moment, the current state is the last appearing in my data).
How can I resample every 3 milliseconds?
EDIT : It seems like DataFrame.resample can also be used for upsampling. Any suggestions on how to use it in my case ? I do not seem to get how it works.