-
Notifications
You must be signed in to change notification settings - Fork 373
Open
Labels
Milestone
Description
The manual shows how to replace values in multiple columns, e.g.
df2 = ifelse.(df .== 999, missing, df)That's a neat trick, but it would be convenient if we had replace and replace! methods for data frames. Something like the following:
df2 = replace(df, :, 999 => missing)
df3 = replace(df, Between(:a, :c), 999 => missing)Of course the eltype conversion behavior would mirror the behavior for Base.replace:
julia> y = [2, 5, 999, 7];
julia> replace(y, 999 => missing)
4-element Array{Union{Missing, Int64},1}:
2
5
missing
7
julia> replace!(y, 999 => missing)
ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type Int64anandijain