Julia DataFrame中的左外部联接问题

克里斯·埃斯沃西(Chris Esworthy)

这个让我难过。

我试图在Julia中加入两个数据框,但出现了这个“无”错误。这可以在另一台机器上工作,所以我认为这可能是包装问题。我一切都Pkg.rm()并重新安装,但没有成功。

朱莉娅v1.2

using PyCall;
using DataFrames;
using CSV;
using Statistics;
using StatsBase;
using Random;
using Plots;
using Dates;
using Missings;
using RollingFunctions;
# using Indicators;
using Pandas;
using GLM;
using Impute;


a = DataFrames.DataFrame(x = [1, 2, 3], y = ["a", "b", "c"])

b = DataFrames.DataFrame(x = [1, 2, 3, 4], z = ["d", "e", "f", "g"])

join(a, b, on=:x, kind =:left)

产量

ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.

Stacktrace:
 [1] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing) at ./show.jl:587
 [2] print_to_string(::String, ::Vararg{Any,N} where N) at ./strings/io.jl:129
 [3] string at ./strings/io.jl:168 [inlined]
 [4] #join#543(::Symbol, ::Symbol, ::Bool, ::Nothing, ::Tuple{Bool,Bool}, ::typeof(join), ::DataFrames.DataFrame, ::DataFrames.DataFrame) at /Users/username/.julia/packages/DataFrames/3ZmR2/src/deprecated.jl:298
 [5] (::getfield(Base, Symbol("#kw##join")))(::NamedTuple{(:on, :kind),Tuple{Symbol,Symbol}}, ::typeof(join), ::DataFrames.DataFrame, ::DataFrames.DataFrame) at ./none:0
 [6] top-level scope at In[15]:4

kind =:inner工作正常,但:left,:right和:outer无效。

BogumiłKamiński

这是由Julia 1.2的打印方式引起的问题nothing(即在尝试打印时出错)。如果您切换到Julia 1.4.1,问题将消失。

但是,我可以看到您在DataFrames.jl 0.21上。在此版本join中,不建议使用功能。您应该使用innerjoinleftjoinrightjoinouterjoin,等功能。然后所有内容都可以在Julia 1.2上使用,例如:

julia> leftjoin(a, b, on=:x)
3×3 DataFrame
│ Row │ x     │ y      │ z       │
│     │ Int64 │ String │ String? │
├─────┼───────┼────────┼─────────┤
│ 1   │ 1     │ a      │ d       │
│ 2   │ 2     │ b      │ e       │
│ 3   │ 3     │ c      │ f       │

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章