当我尝试将多个DataFrames
(来自DataFrames
包的数据结构!)与相同的列但不同的行号连接起来时,我遇到了问题。这是我的代码:
using(DataFrames)
DF = DataFrame()
DF[:x1] = 1:1000
DF[:x2] = rand(1000)
DF[:time] = append!( [0] , cumsum( diff(DF[:x1]).<0 ) ) + 1
DF1 = DF[DF[:time] .==1,:]
DF2 = DF[DF[:time] .==round(maximum(DF[:time])),:]
DF3 = DF[DF[:time] .==round(maximum(DF[:time])/4),:]
DF4 = DF[DF[:time] .==round(maximum(DF[:time])/2),:]
DF1[:T] = "initial"
DF2[:T] = "final"
DF3[:T] = "1/4"
DF4[:T] = "1/2"
DF = [DF1;DF2;DF3;DF4]
最后一行给出了错误
MethodError: Cannot `convert` an object of type DataFrames.DataFrame to an object of type LastMain.LastMain.LastMain.DataFrames.AbstractDataFrame
This may have arisen from a call to the constructor LastMain.LastMain.LastMain.DataFrames.AbstractDataFrame(...),
since type constructors fall back to convert methods.
我不明白这条错误信息。你能帮我吗?谢谢!
答案 0 :(得分:3)
我刚刚在Julia 0.5.0 x86_64-linux-gnu,DataFrames 0.8.5,hcat
和vcat
上遇到了这个问题。
清除工作区和重新加载DataFrames都没有解决问题,但重新启动REPL会立即修复它。