Recommendations for flexible time series data?

Much like this person on Stackoverflow I’ve got data that are time series data but where the time indices are not DateTime (they are just processor ticks converted to microseconds). I looked at TimeSeries.jl and TS but they are strict about the time indices being TimeType – then I waded into the bewildering forest of NamedDims / AxisArray / DimensionalData – but most of these seem to not have the ability to merge multiple arrays (e.g, overlapping time series) or align data etc. I guess before I just go do my own thing I wanted to ask once here: Does anyone know of a library with actual time series functionality but that is not militant about TimeType?

Edit to add: in case it affects any recommendations the values of the time series are going to be vectors / images, etc not just DataFrames style things.

I guess the range of time values is too large for the Time type?

A thing I would try is define a new TimeType that wraps the microsecond values.

Can you expand on what you mean regarding data frames? A DataFrame in Julia is a generic container, you can put vectors or images inside…

In case you haven’t seen it: you might find this thread useful.

Hopefully someone with more experience with time series will chime in…

Yeah, I tried a

struct MyTime <: TimeType
  instant::Int
end

before I posted here but it complained about Int not having a period and I couldn’t find a good definition of what the “protocol” was and since I couldn’t see the bottom of the rabbit hole I figured I’d just ask here. I’ll probably just write my own thing. I think I spent 2 hours doing github archeology when I could have just solved the problem in 30 minutes.

Edit: Indeed, it took me about 20 minutes to solve this without any libraries :man_facepalming:

You can also use IndexedTables. IMHO, it has till now most functionality for handling timeseries like data.

using JuliaDB

## create t1 using some data ##

julia> t1
Table with 30 rows, 2 columns:
year  value
────────────
1875  580.38
1876  581.86
1877  580.97
1878  580.8
1879  579.79
1880  580.39
1881  580.42
1882  580.82
1883  581.4
1884  581.32
1885  581.44
1886  581.68
1887  581.17
1888  580.53
1889  580.01
1890  579.91
1891  579.14
1892  579.16
1893  579.55
1894  579.67
1895  578.44
1896  578.24
1897  579.1
1898  579.09
1899  579.35
1900  578.82
1901  579.32
1902  579.01
1903  579.0
1904  579.8

## index is integers
julia> eltype(t1)
NamedTuple{(:year, :value),Tuple{Int64,Float64}}

## pull out some data from t1 to create t2
julia> t2 = table(t1[sort(sample(1:length(t1), 10, replace=false))], pkey = :year)
Table with 10 rows, 2 columns:
year  value
────────────
1879  579.79
1881  580.42
1882  580.82
1883  581.4
1884  581.32
1885  581.44
1888  580.53
1895  578.44
1900  578.82
1901  579.32

## merge using common values of primary key and leave the rest
julia> naturaljoin(t1, t2)
Table with 10 rows, 2 columns:
year  value
────────────
1879  579.79
1881  580.42
1882  580.82
1883  581.4
1884  581.32
1885  581.44
1888  580.53
1895  578.44
1900  578.82
1901  579.32

# automatically inserts missing
julia> leftjoin(t1, t2)
Table with 30 rows, 2 columns:
year  value
─────────────
1875  missing
1876  missing
1877  missing
1878  missing
1879  579.79
1880  missing
1881  580.42
1882  580.82
1883  581.4
1884  581.32
1885  581.44
1886  missing
1887  missing
1888  580.53
1889  missing
1890  missing
1891  missing
1892  missing
1893  missing
1894  missing
1895  578.44
1896  missing
1897  missing
1898  missing
1899  missing
1900  578.82
1901  579.32
1902  missing
1903  missing
1904  missing
1 Like