# Recommendations for flexible time series data?

**URL:** https://discourse.julialang.org/t/recommendations-for-flexible-time-series-data/75776
**Category:** Data
**Tags:** time-series
**Created:** [February 4, 2022, 6:12am UTC](https://discourse.julialang.org/t/recommendations-for-flexible-time-series-data/75776 "2022-02-04T06:12:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dfarmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfarmer/32/21616_2.png) [@dfarmer](https://discourse.julialang.org/u/dfarmer)
#### Post date: [February 4, 2022, 6:12am UTC](https://discourse.julialang.org/t/recommendations-for-flexible-time-series-data/75776/1 "2022-02-04T06:12:46Z")

</div>

Much like this person on [Stackoverflow](https://stackoverflow.com/questions/59842771/can-i-use-a-non-date-type-as-the-time-index-of-a-timeseries-object-in-julia) 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._

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [February 4, 2022, 8:59am UTC](https://discourse.julialang.org/t/recommendations-for-flexible-time-series-data/75776/2 "2022-02-04T08:59:29Z")

</div>

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](https://discourse.julialang.org/t/time-series-in-julia-working-list/62539) useful.

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

---

<div class="post-metadata">

### Author: ![dfarmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfarmer/32/21616_2.png) [@dfarmer](https://discourse.julialang.org/u/dfarmer)
#### Post date: [February 5, 2022, 6:18am UTC](https://discourse.julialang.org/t/recommendations-for-flexible-time-series-data/75776/3 "2022-02-05T06:18:09Z")

</div>

Yeah, I tried a

```julia
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 🤦‍♂️_

---

<div class="post-metadata">

### Author: ![chiraganand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chiraganand/32/32787_2.png) [@chiraganand](https://discourse.julialang.org/u/chiraganand)
#### Post date: [February 18, 2022, 10:43am UTC](https://discourse.julialang.org/t/recommendations-for-flexible-time-series-data/75776/4 "2022-02-18T10:43:18Z")

</div>

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

```julia
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

```
