2021年3月25日星期四

Julia writing DataFrame to csv fails UndefRefError: access to undefined reference

So I simply want to write a DataFrame to a csv file (or xlsx). But after executing the code to populate the DataFrame and being able to see it in the console, I cannot save it. (neither to .csv or .xlsx with the CSV package or the xlsx package loaded).

MWE:

using DataFrames  using CSV  df = DataFrame([String,Float64,Float64],["a","b","c"], 1000)  CSV.write("Trial_Julia_Output.csv", df)  

This fails with

UndefRefError: access to undefined reference

What am I doing wrong?

Stacktrace:

 [1] getindex(::Array{String,1}, ::Int64) at .\array.jl:809   [2] getindex at C:\Users\chris\.julia\packages\DataFrames\oQ5c7\src\dataframe\dataframe.jl:400 [inlined]   [3] getindex at C:\Users\chris\.julia\packages\DataFrames\oQ5c7\src\dataframerow\dataframerow.jl:212 [inlined]   [4] getcolumn(::DataFrameRow{DataFrame,DataFrames.Index}, ::Symbol) at C:\Users\chris\.julia\packages\DataFrames\oQ5c7\src\other\tables.jl:31   [5] getcolumn at C:\Users\chris\.julia\packages\Tables\UxLRG\src\Tables.jl:101 [inlined]   [6] eachcolumn at C:\Users\chris\.julia\packages\Tables\UxLRG\src\utils.jl:70 [inlined]   [7] writerow(::Array{UInt8,1}, ::Base.RefValue{Int64}, ::Int64, ::IOStream, ::Tables.Schema{(:a, :b, :c),Tuple{String,Float64,Float64}}, ::DataFrameRow{DataFrame,DataFrames.Index}, ::Int64, ::CSV.Options{UInt8,UInt8,Nothing,Tuple{},CSV.var"#60#63"}) at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:342   [8] #66 at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:215 [inlined]   [9] (::CSV.var"#73#74"{CSV.var"#66#67"{Bool,Bool,Tables.Schema{(:a, :b, :c),Tuple{String,Float64,Float64}},DataFrames.DataFrameRows{DataFrame,DataFrames.Index},CSV.Options{UInt8,UInt8,Nothing,Tuple{},CSV.var"#60#63"},Tuple{Symbol,Symbol,Symbol},Int64,Int64,Array{UInt8,1}}})(::IOStream) at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:279   [10] open(::CSV.var"#73#74"{CSV.var"#66#67"{Bool,Bool,Tables.Schema{(:a, :b, :c),Tuple{String,Float64,Float64}},DataFrames.DataFrameRows{DataFrame,DataFrames.Index},CSV.Options{UInt8,UInt8,Nothing,Tuple{},CSV.var"#60#63"},Tuple{Symbol,Symbol,Symbol},Int64,Int64,Array{UInt8,1}}}, ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\io.jl:325   [11] open at .\io.jl:323 [inlined]   [12] with at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:278 [inlined]   [13] #write#65 at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:205 [inlined]   [14] write(::String, ::DataFrame; delim::Char, quotechar::Char, openquotechar::Nothing, closequotechar::Nothing, escapechar::Char, newline::Char, decimal::Char, dateformat::Nothing, quotestrings::Bool, missingstring::String, transform::CSV.var"#60#63", bom::Bool, append::Bool, writeheader::Nothing, partition::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:191   [15] write(::String, ::DataFrame) at C:\Users\chris\.julia\packages\CSV\CJfFO\src\write.jl:152   [16] top-level scope at In[36]:2   [17] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091  
https://stackoverflow.com/questions/66809741/julia-writing-dataframe-to-csv-fails-undefreferror-access-to-undefined-referenc March 26, 2021 at 09:19AM

没有评论:

发表评论