diff --git a/src/TSFrame.jl b/src/TSFrame.jl index 705794d..10f6faa 100644 --- a/src/TSFrame.jl +++ b/src/TSFrame.jl @@ -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) @@ -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 diff --git a/src/rollapply.jl b/src/rollapply.jl index 3cf0d3a..ce68940 100644 --- a/src/rollapply.jl +++ b/src/rollapply.jl @@ -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)