Skip to content

Commit

Permalink
Revert changes by removing hack in TSFrames
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Feb 27, 2023
1 parent 2af8ca7 commit 0f434a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/TSFrame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ struct TSFrame

sorted_cd = issorted ? (copycols ? copy(coredata) : coredata) : sort(coredata, index)

if (index isa Symbol && index == :Index) || (index isa String && index == "Index")
return new(sorted_cd)
end

index_vals = sorted_cd[!, index]
cd = sorted_cd[:, Not(index)]
insertcols!(cd, 1, :Index => index_vals, after=false, copycols = copycols)
Expand Down Expand Up @@ -417,6 +413,6 @@ end
# For empty TSFrames
function TSFrame(IndexType::DataType, cols::Vector{Tuple{DataType, S}}; issorted = false, copycols = true) where S <: Union{Symbol, String}
df = DataFrame([colname => type[] for (type, colname) in cols])
insertcols!(df, :Index => IndexType[])
insertcols!(df, 1, :Index => IndexType[]; after = false, copycols = false)
TSFrame(df; issorted = issorted, copycols = copycols)
end
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)])
DataFrames.insertcols!(res, 1, :Index => TSFrames.index(ts)[windowsize:end]; after = false, copycols = false)
res[:, :Index] = TSFrames.index(ts)[windowsize:end]
return TSFrame(res)
else
res_df = DataFrame(Index=TSFrames.index(ts)[windowsize:end], outputs=res)
Expand Down

0 comments on commit 0f434a5

Please sign in to comment.