Inside the function splitcolumn(F)
the variable F behaves like a global variable?!!
julia> using Dates, DataFrames, BenchmarkTools
julia> F = DataFrame(Number=[73,80,85,62],
DateTime=["2022-03-21T20:00:00",
"2022-03-21T19:56:00",
"2022-03-21T19:47:00",
"2022-03-21T19:15:00"])
4x2 DataFrame
Row │ Number DateTime
│ Int64 String
─────┼─────────────────────────────
1 │ 73 2022-03-21T20:00:00
2 │ 80 2022-03-21T19:56:00
3 │ 85 2022-03-21T19:47:00
4 │ 62 2022-03-21T19:15:00
julia> F.DateTime = DateTime.(F.DateTime, DateFormat("y-m-dTH:M:SZ"))
4-element Vector{DateTime}:
2022-03-21T20:00:00
2022-03-21T19:56:00
2022-03-21T19:47:00
2022-03-21T19:15:00
julia> F
4x2 DataFrame
Row │ Number DateTime
│ Int64 DateTime
─────┼─────────────────────────────
1 │ 73 2022-03-21T20:00:00
2 │ 80 2022-03-21T19:56:00
3 │ 85 2022-03-21T19:47:00
4 │ 62 2022-03-21T19:15:00
julia> function splitcolumn(F)
G = DataFrame(Date = Date.(F.DateTime),Time = Time.(F.DateTime))
F = select!(F, Not([:DateTime]))
F = hcat(G,F)
end
splitcolumn (generic function with 1 method)
julia> @btime splitcolumn(F)
ERROR: ArgumentError: column name :DateTime not found in the data frame
Stacktrace:
[1] lookupname
@ C:\Users\Hermesr\.julia\packages\DataFrames\6xBiG\src\other\index.jl:392 [inlined]
[2] getindex
@ C:\Users\Hermesr\.julia\packages\DataFrames\6xBiG\src\other\index.jl:401 [inlined]
[3] getindex(df::DataFrame, #unused#::typeof(!), col_ind::Symbol)
@ DataFrames C:\Users\Hermesr\.julia\packages\DataFrames\6xBiG\src\dataframe\dataframe.jl:525
[4] getproperty
@ C:\Users\Hermesr\.julia\packages\DataFrames\6xBiG\src\abstractdataframe\abstractdataframe.jl:378 [inlined]
[5] splitcolumn(F::DataFrame)
@ Main .\REPL[13]:2
[6] var"##core#303"()
@ Main C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:489
[7] var"##sample#304"(::Tuple{}, __params::BenchmarkTools.Parameters)
@ Main C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:495
[8] _run(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; verbose::Bool, pad::String, kwargs::Base.Pairs{Sym
bol, Integer, NTuple{4, Symbol}, NamedTuple{(:samples, :evals, :gctrial, :gcsample), Tuple{Int64, Int64, Bool, Bool}}})
@ BenchmarkTools C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:99
[9] #invokelatest#2
@ .\essentials.jl:718 [inlined]
[10] #run_result#45
@ C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:34 [inlined]
[11] run(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Float
64, kwargs::Base.Pairs{Symbol, Integer, NTuple{5, Symbol}, NamedTuple{(:verbose, :samples, :evals, :gctrial, :gcsample),
Tuple{Bool, Int64, Int64, Bool, Bool}}})
@ BenchmarkTools C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:117
[12] #warmup#54
@ C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:169 [inlined]
[13] tune!(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Flo
at64, verbose::Bool, pad::String, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ BenchmarkTools C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:250
[14] tune! (repeats 2 times)
@ C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:250 [inlined]
[15] top-level scope
@ C:\Users\Hermesr\.julia\packages\BenchmarkTools\7xSXH\src\execution.jl:576
julia> F
4x1 DataFrame
Row │ Number
│ Int64
─────┼────────
1 │ 73
2 │ 80
3 │ 85
4 │ 62
julia> G
ERROR: UndefVarError: G not defined