I was trying to get a multiple conditional statement running and I keep hitting an error.
df1 = @chain df begin
@transform(:Business_Type = if :Business_Type .== "Corporate Travel Department (CTD)"
:Business_Type ="Corporate"
elseif :Business_Type .== "Cruise"
:Business_Type = "Leisure"
elseif :Business_Type .== "Corporate"
:Business_Type ="Corporate"
elseif :Business_Type .== "Leisure"
:Business_Type = "Leisure"
elseif :Business_Type .== "Travel Management Company"
:Business_Type ="Unkown"
elseif :Business_Type .== "Tour Operator"
:Business_Type ="Unknown"
else "Unknown"
end)
@select(:Business_Type, :trip_type, :travellers, :haul, :cabin_class, :legs, :travel_dow, :businessday
,:trip_length_days, :lead_time, :businessdaytotal, :travel_month, :DBA_Name, :iata, :pcc)
end
The error message is:
ERROR: TypeError: non-boolean (Vector{Union{Missing, Bool}}) used in boolean context
The example I used was:
if g == 0
0
elseif g == 1
10
elseif g == 2
20
elseif g == 3
30
elseif g == 4
40
else
50
end
I think the complication Iβm having is dealing with casting it to every row and doing it within a @transform statementβ¦ I was looking at the @byrow command but it seems like it can only use one argument:
@transform(df, @byrow :y = :x == 1 ? true : false)
@byrow
accepts a single argument and creates an anonymous function wrapped inByRow
Thoughts?