FYI: pandas version is 1.3.4 for now
I have currently working code to interpolate non-monotonous timestamps (along with various other data not sampled monotonously) into a dataframe out with a monotonous (float-type) time index. The important part is here:
out = out.join(dateTime_df.astype('int64'),
how = 'outer',
).interpolate(method = 'linear',
limit_area = 'inside',
).loc[index] #`index` is the monotonous time index
out["DateTime_col"] = out["DateTime_col"].astype('<M8[ns]')
This currently works, but throws a FutureWarning:
FutureWarning: casting datetime64[ns] values to int64 with .astype(...) is deprecated and will raise in a future version. Use .view(...) instead.
I'm wondering what the "right" way to do this would be, using .view(), as it doesn't seem like DataFrame has a view method (at least in my ancient pandas version 1.3.4 I'm stuck with for now). I'm somewhat afraid to update my pandas version until I have a fix.
Edit: adding test data:
out = pd.DataFrame(np.random.rand(10, 3),
columns = ['previously', 'imported', 'data'])
dateTime_df = pd.DataFrame([datetime.datetime.now() - datetime.timedelta(days = 1),
datetime.datetime.now()],
index = [3, 7],
columns = ["DateTime_col"])
index = np.arange(10)