using DataFrames
label = ["Data", "tempo", "RAh", "RAm", "RAs", "DEh", "DEm", "DEs"]
df = readtable("mars.dat", separator = ' ',header = false, names = label)
我收到了下一个错误
MethodError: no method matching DataFrames.ParseOptions(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Array{String,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool)
Closest candidates are:
DataFrames.ParseOptions(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{S<:String,1}, ::Array{T<:String,1}, ::Array{T<:String,1}, ::Bool, ::Array{Symbol,1}, ::Array{T,1} where T, ::Bool, ::Char, ::Bool, ::Int64, ::AbstractArray{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool) where {S<:String, T<:String} at /home/juser/.julia/v0.6/DataFrames/src/dataframe/io.jl:9
Stacktrace:
[1] #readtable#84(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{String,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::DataFrames.#readtable, ::IOStream, ::Int64) at /home/juser/.julia/v0.6/DataFrames/src/dataframe/io.jl:843
[2] (::DataFrames.#kw##readtable)(::Array{Any,1}, ::DataFrames.#readtable, ::IOStream, ::Int64) at ./<missing>:0
[3] #readtable#85(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{String,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::DataFrames.#readtable, ::String) at /home/juser/.julia/v0.6/DataFrames/src/dataframe/io.jl:945
[4] (::DataFrames.#kw##readtable)(::Array{Any,1}, ::DataFrames.#readtable, ::String) at ./<missing>:0
答案 0 :(得分:1)
从readtable的文档中,似乎它需要一个符号向量,而不是字符串向量:
names :: Vector {Symbol} - 使用此数组中的值作为所有列的名称,而不是或代替文件头中的名称。
您可以将字符串向量转换为带符号列表的符号向量(假设您的字符串是有效名称),例如
labelSymbols = [Symbol(i) for i in label];
并将其传递给您的名字参数。
免责声明:我没有测试过这是否有效,因为我无法访问mars.dat
文件。我只是阅读文档并指出最可能出现的问题。