mcabbott / mcabbott/AxisKeys.jl

request - running lag function

Open
#177 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
154
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Sample function shown below for 1-dimension case.
General case would be more complex.
Useful for running differences.

using AxisKeys, Dates

data    = 1:10                             |> collect
date    = Date(2000,1,1):Date(2000,1,10)   |> collect 
ka      = KeyedArray( data; date,   )


function lagwise( ka::KeyedArray, dim::Symbol, n::Int, data_func::Function, dim_func::Function )

    data  = data_func.(   ka.data.data[1+n:end],      ka.data.data[1:end-n]       )

    dimV  = dim_func.(    axiskeys(ka,dim)[1:end-n],  axiskeys(ka,dim)[1+n:end]   )

    KeyedArray( data, dimV )

end


lagwise( ka, :date, 2, -, tuple )

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing KeyedArray, axiskeys, and data access APIs used in the sample lagwise function. Determine how a lag operation should handle arbitrary dimensions and construct the resulting keys; done means a tested running-difference operation that preserves the expected data and dimension keys.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.