JuliaDB.jl icon indicating copy to clipboard operation
JuliaDB.jl copied to clipboard

Is there any thing like discrete difference?

Open clouds56 opened this issue 6 years ago • 1 comments
trafficstars

Like what's in pandas, http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.diff.html, or more generally http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shift.html

clouds56 avatar Jun 15 '19 10:06 clouds56

I think the answer is no. I usually do the following:

t = table((date = [Date(2007,12,31), Date(2008,12,31), Date(2009,12,31)], value = [2.1, 4.2, 8.1]))
t = @transform t {date_last_year = :date - Dates.Year(1)}
t = join(t, renamecol(t, :value, :value_last_year), 
    lkey = :date_last_year, rkey = :date, rselect = :value_last_year, how = :left)
t = @transform t {difference = :value - :value_last_year}
t = popcol(t, (:date_last_year, :value_last_year))
t = reindex(t, :date)

It is a bit bulky, but you have maximal control over what goes on.

But your feature request may well be warranted!

MaximilianJHuber avatar Jun 18 '19 13:06 MaximilianJHuber