Interpolate One Time Series Onto Custom Time Series
Goal: Interpolate one time series onto another custom time series. I checked stack overflow and found the following solution. However, I get the following error: ValueError: ca
Solution 1:
You didn't provide enough information so I created my own. You will have to pay attention and adjust this to suit your needs.
This answer was given for this question.
setup
p = pd.DataFrame(
dict(
Pressure=[101155, 101152, 101150, 101151, 101151],
Quality=[3, 3, 3, 3, 3]
),
pd.Index([0, 10, 20, 30, 40], name='Timestamp')
)
a = [5, 12, 18, 24, 33, 35, 37]
general strategy
- make sure timestamp is in index of
p
- take a union of
p.index
(your timestamp) and the new time lista
- reindex with the union. NaN's will show up for 'new' index values.
- when you interpolate, use
method='index'
DOCUMENTATION
code
idx = p.index.union(a)
p.reindex(idx).interpolate('index')
p
idx = p.index.union(a)
p.reindex(idx).interpolate('index')
Post a Comment for "Interpolate One Time Series Onto Custom Time Series"