Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Pandas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ end

for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul__),
(:/, :__div__, :__rdiv__), (:-, :__sub__, :__rsub__),
(:(==), :__eq__, :__eq__), (:!=, :__ne__, :__ne__),
(:>, :__gt__, :__lt__), (:<, :__lt__, :__gt__),
(:>=, :__ge__, :__le__), (:<=, :__le__, :__ge__),
(:&, :__and__, :__and__), (:|, :__or__, :__or__)]
Expand All @@ -397,6 +396,19 @@ for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul
end
end

# Special-case the handling of equality-testing to always consider PandasWrapped
# objects as unequal to non-wrapped objects.
(==)(x::PandasWrapped, y) = false
(==)(x, y::PandasWrapped) = false
(!=)(x::PandasWrapped, y) = true
(!=)(x, y::PandasWrapped) = true
function (==)(x::PandasWrapped, y::PandasWrapped)
pandas_wrap(x.pyo.__eq__(y))
end
function (!=)(x::PandasWrapped, y::PandasWrapped)
pandas_wrap(x.pyo.__neq__(y))
end

for op in [(:-, :__neg__)]
@eval begin
$(op[1])(x::PandasWrapped) = pandas_wrap(x.pyo.$(quot(op[2]))())
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ julia_df = DataFrames.DataFrame(py_df)
julia_df= DataFrames.DataFrame(C = 1:4, A = 5:8, B = 9:12)
py_df = Pandas.DataFrame(julia_df)
@test all(Pandas.columns(py_df) .== ["C","A","B"])

df1 = Pandas.Series(1:2)
df2 = Pandas.Series(1:2)
df3 = Pandas.Series(3:4)

@test all(df1 == df1)
@test all(df1 == df2)
@test df1 != [1, 2]