Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

min/max on differences of DataFrame columns in Julia #1150

Closed
cocoandmore opened this issue Jan 22, 2017 · 1 comment
Closed

min/max on differences of DataFrame columns in Julia #1150

cocoandmore opened this issue Jan 22, 2017 · 1 comment

Comments

@cocoandmore
Copy link

When I try to retrieve the maximums of differences of columns in a DataFrame I get an error. What is wrong?

using DataFrames

a = [2,4,10,4,8,8]
b = [5,9,7,2,8,7]
c = [2,9,7,6,8,1]

df = DataFrame(A = a, B = b, C = c)
df[2,:A] = NA
df[3,:C] = NA

ab=df[:A] - df[:B]
bc=df[:B] - df[:C]
ac=df[:A] - df[:C]

df[:max] = max(ab, bc, ac)

println(df)

=> LoadError: MethodError: no method matching isless(::DataArrays.DataArray{Int64,1}, ::Array{Any,1})

Doing the maximum of either df[:max] = max(ab, bc) or df[:max] = max(a, b, c) works as expected.

Can anybody clarify what's going on? Thank you!

@nalimilan
Copy link
Member

Thanks for the report. Sounds like a bug in DataArrays, which is going to be deprecated. Anyway the recommended syntax is now df[:max] = max.(ab, bc, ac), and AFAICT it works both with 0.8.4 and git master (at least after JuliaStats/NullableArrays.jl#166).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants