Skip to content

ERROR: UndefVarError: T not defined #124

@ufechner7

Description

@ufechner7

Code:

using CSV, DataFrames, Impute

function logfiles()
    files=readdir("data")
    filter!(files -> occursin(r"log_", files), files)
    non_empty_files = String[]
    for file in files
        if stat("data/" * file).size > 2000
            push!(non_empty_files, file)
        end
    end
    non_empty_files
end

function read_log(logfiles)
    df = nothing
    t_end = 0
    for logfile in logfiles
        df_new = CSV.read("data/" * logfile, DataFrame)
        if isnothing(df)
            df=df_new
            t_end = last(df.TIME)
        else
            t_start = first(df_new.TIME)
            if (t_start - t_end) > 60
               n = div(t_start - t_end + 30, 60)
               v = fill(missing, size(df)[2]-1)
               println("Missing: ", n, " minutes") 
               allowmissing!(df)
               for i in 1:n
                   v1 = vcat([i*60+t_end], v)
                   push!(df, v1)
               end
            end
            df = outerjoin(df, df_new, matchmissing=:equal, on = intersect(names(df),  names(df_new)))
            t_end = last(df.TIME)
        end
    end

    df = Impute.interp(df)
return

df = read_log(logfiles())

Error message:

ERROR: UndefVarError: T not defined
Stacktrace:
  [1] _impute!(data::Vector{Any}, imp::Impute.Interpolate)
    @ Impute ~/.julia/packages/Impute/AB7zS/src/imputors/interp.jl:55
  [2] impute!(data::Vector{Any}, imp::Impute.Interpolate; dims::Function, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Impute ~/.julia/packages/Impute/AB7zS/src/imputors.jl:127
  [3] impute!(data::Vector{Any}, imp::Impute.Interpolate)
    @ Impute ~/.julia/packages/Impute/AB7zS/src/imputors.jl:127
  [4] impute!(table::DataFrame, imp::Impute.Interpolate; cols::Nothing)
    @ Impute ~/.julia/packages/Impute/AB7zS/src/imputors.jl:232
  [5] impute!
    @ ~/.julia/packages/Impute/AB7zS/src/imputors.jl:224 [inlined]
  [6] #impute#8
    @ ~/.julia/packages/Impute/AB7zS/src/imputors.jl:80 [inlined]
  [7] impute
    @ ~/.julia/packages/Impute/AB7zS/src/imputors.jl:80 [inlined]
  [8] interp(data::DataFrame; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Impute ~/.julia/packages/Impute/AB7zS/src/functional.jl:76
  [9] interp(data::DataFrame)
    @ Impute ~/.julia/packages/Impute/AB7zS/src/functional.jl:75
 [10] read_log(logfiles::Vector{String})
    @ Main ~/repos/trader/src/logging.jl:45
 [11] top-level scope
    @ REPL[2]:1

Installed packages:

pkg> st
      Status `~/repos/trader/Project.toml`
  [336ed68f] CSV v0.9.11
  [8f4d0f93] Conda v1.5.2
  [a93c6f00] DataFrames v1.2.2
  [587475ba] Flux v0.12.8
  [53d20848] FluxArchitectures v0.1.3
  [38e38edf] GLM v1.5.1
  [cd3eb016] HTTP v0.9.17
  [f7bf1975] Impute v0.6.7
  [682c06a0] JSON v0.21.2
  [0f8b85d8] JSON3 v1.9.2
  [9b87118b] PackageCompiler v2.0.2
  [d96e819e] Parameters v0.12.3
  [58dd65bb] Plotly v0.4.1
  [f0f68f2c] PlotlyJS v0.18.8
  [91a5bcdd] Plots v1.24.2
  [438e738f] PyCall v1.92.5
  [d330b81b] PyPlot v2.10.0
  [f269a46b] TimeZones v1.6.2
  [de0858da] Printf
  [10745b16] Statistics

Julia version 1.6.3 on Ubuntu Linux 18.04.

Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions