SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.04k stars 139 forks source link

#group_by with boolean gives `ArgumentError: comparison of Array with Array failed` #324

Open dansbits opened 7 years ago

dansbits commented 7 years ago

I was recently trying to get a count of true and false values in a column of my data frame and received ArgumentError: comparison of Array with Array failed when I tried to run group_by using only that column. I thought this might be something with my data set but the below example reproduces the error.

df = Daru::DataFrame.new({ id: (1..10).to_a, is_training: (1..10).to_a.map { rand(2) == 0 } })
df.group_by([:is_training]).count
zverok commented 7 years ago

I believe it is due to the fact that currently group_by for some reason sorts groups, and booleans can't be compared with <=>. This redesign ticket is somehow related: https://github.com/SciRuby/daru/issues/152