xKDR / TSFrames.jl

Timeseries in Julia
MIT License
92 stars 22 forks source link

Proposal: user-defined time index interface #167

Open sairus7 opened 12 months ago

sairus7 commented 12 months ago

Some time ago there was a detailed discussion about TimeSeries.jl functionality. In particular there was an idea to define a separate timestamps vector that support different time types: https://github.com/JuliaStats/TimeSeries.jl/issues/482#issuecomment-778704466

The main reason for it is to support different time representations:

Is there any plans or interest to support such functionality in this package?

chiraganand commented 6 months ago

Some time ago there was a detailed discussion about TimeSeries.jl functionality. In particular there was an idea to define a separate timestamps vector that support different time types: JuliaStats/TimeSeries.jl#482 (comment)

TSFrames already separates out index from data. In its simplest form:

struct TSFrame
    coredata :: DataFrame
end

The first column of the DataFrame is the index. This is done to provide the flexibility to support other types of index.

Having said that, there is plan to implement custom typed index for TSFrame. Currently, the index is <: Union{Int, TimeType} but it can, essentially, be any type as long as it can be sorted (I can't remember anything else but I am sure there are a few other constraints).

There is some related discussion in #151.

The main reason for it is to support different time representations:

As I mentioned above, ideally, these should be possible.

  • scales from milliseconds to days and years,

This is already possible with DateTime index. There are functions to support this scaling like to_period() and endpoints(). For applying a function over a period there is apply().

If I understand from what you are asking, this indexing is already possible. See: https://xkdr.github.io/TSFrames.jl/stable/user_guide/#Indexing-and-subsetting For some reason, the API reference doc isn't being generated for all the getindex() overloads but you can look at the source here: https://github.com/xKDR/TSFrames.jl/blob/main/src/getindex.jl.

Is there any plans or interest to support such functionality in this package?

Already answered above.