Is there a simple way to logically index a DataFrame?
For example, if I want to keep every row that has a 1
and discard every row that has a 0
in the column x
df[:, :x] .== 1
This returns a BitArray
of Bool
how would I use this BitArray
to filter the entire DataFrame?
This seems to work!
filter(:x => isequal(1), df)
Yes, that's the way - there's also the in-place version filter!
, and @view df[df.x .== 1, :]
Last updated: Dec 28 2024 at 04:38 UTC