Skip to content

Commit

Permalink
Fix order of index in TSFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Feb 27, 2023
1 parent 0f638bb commit 2af8ca7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/TSFrame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ end
# FIXME: use Metadata.jl
function TSFrame(coredata::AbstractArray{T,2}; colnames=:auto, issorted = false, copycols = true) where {T}
index_vals = collect(Base.OneTo(size(coredata)[1]))
df = DataFrame(coredata, colnames, copycols=true)
df = DataFrame(coredata, colnames, copycols=copycols)
TSFrame(df, index_vals; issorted = issorted, copycols = copycols)
end

Expand All @@ -410,7 +410,7 @@ end
function TSFrame(IndexType::DataType; n::Int=1, issorted = false, copycols = true)
(n>=1) || throw(DomainError(n, "n should be >= 1"))
df = DataFrame(fill([],n), :auto)
df.Index = IndexType[]
insertcols!(df, 1, :Index => IndexType[]; after = false, copycols = false)
TSFrame(df; issorted = issorted, copycols = copycols)
end

Expand Down
2 changes: 1 addition & 1 deletion src/rollapply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function rollapply(ts::TSFrame, fun::Function, windowsize::Int; bycolumn=true)

if bycolumn
DataFrames.rename!(res, [col => string("rolling_", col, "_", Symbol(fun)) for col in propertynames(res)])
res[:, :Index] = TSFrames.index(ts)[windowsize:end]
DataFrames.insertcols!(res, 1, :Index => TSFrames.index(ts)[windowsize:end]; after = false, copycols = false)
return TSFrame(res)
else
res_df = DataFrame(Index=TSFrames.index(ts)[windowsize:end], outputs=res)
Expand Down

0 comments on commit 2af8ca7

Please sign in to comment.