Replies: 2 comments 2 replies
|
I am okay with this but I don't have much experience on time series. So I will ask you to put enough unit tests. |
|
One motivation for providing time range features is aligning time series data for further processing. One example would be processing ts data sampled roughly secondly but nevertheless not aligning. One wants to align/resample/reindex each series to sum them. import java.time.LocalTime
import org.saddle._
val s1 = Series(LocalTime("00:00:00.112") -> 1.2, LocalTime("00:00:01.122") -> 1.5, LocalTime("00:00:02.117") -> 1.3, ...)
val s2 = Series(LocalTime("00:00:00.113") -> 0.9, LocalTime("00:00:01.125") -> 1.2, LocalTime("00:00:02.116") -> 1.1, ...)
val sum = ???In saddle, what is the idiomatic way of resampling both series and adding them? Here is an option in python with pandas import pandas as pd
range = pd.date_range(pd.Timestamp("00:00:00"), pd.Timestamp("00:00:02"))
s1 = pd.Series({pd.Timestamp("00:00:00.112"): -> 1.2, pd.Timestamp("00:00:01.122"): 1.5, pd.Timestamp("00:00:02.117"): 1.3}, ...)
s2 = pd.Series(pd.Timestamp("00:00:00.113") -> 0.9, pd.Timestamp("00:00:01.125"): 1.2, pd.Timestamp("00:00:02.116"): 1.1}, ...)
val sum = (
pd.concat([s1, s2], axis='columns') # concat returns a DataFrame
.resample("1s")
.ffill() # forward fill, fill NA values with present ones forward
.sum(axis='columns'))
# or
range = pd.date_range(pd.Timestamp("00:00:00"), pd.Timestamp("00:00:02"), freq="1s")
sum = (
pd.concat([s1, s2], axis='columns')
.reindex(range, method='ffill') # similar to .resample().ffill()
.sum(axis='columns'))I see these tracks for extending saddle in this area:
Let me know if I'm missing on saddle features that cover parts of the discussion here. |
Uh oh!
There was an error while loading. Please reload this page.
Hello here,
I'm experimenting a bit with a generic
IndexRange[S, T]and aStepper[S, T]. The end goal is introducing a new operation on the series and frames along this type signature:An instance of
Stepperwould be provided for java.time or joda types, for exampleStepper[Duration, Instant]orStepper[Duration, LocalDateTime]etc.This is an attempt at providing equivalent capabilities to
resamplefrom pandas.The work is in an early stage. But I'm open to early feedback on this and see if there is interest in adding this to saddle.
All reactions