Case When Statement - in a receipe
Data123
Registered Posts: 4 ✭✭✭✭
Hi everyone,
FYI i am very new to DataIKU so apologies if this is an obvious question
I need to add extra columns to my data based on variables/definition - I know this can be done in the lab - formula - I was hoping I could do this I a recipe i.e
Select team_a
Case when team_a= 1 then 'A'
else 'NA'
End as 'Team_2'
From Test
Is this possible anywhere ? None of the recipes seem to recognize case when etc ? And its been talked about on the forum i think i am just missing where this should go
Thank you
FYI i am very new to DataIKU so apologies if this is an obvious question
I need to add extra columns to my data based on variables/definition - I know this can be done in the lab - formula - I was hoping I could do this I a recipe i.e
Select team_a
Case when team_a= 1 then 'A'
else 'NA'
End as 'Team_2'
From Test
Is this possible anywhere ? None of the recipes seem to recognize case when etc ? And its been talked about on the forum i think i am just missing where this should go
Thank you
Answers
-
Hello, You can use the 'find and replace' processor in a Prepare recipe to do that. This is explained here: https://doc.dataiku.com/dss/latest/preparation/processors/find-replace.html. Hope it helps, Alexandre
-
Hi, I can't see in the link how to specify the Else condition. I have a column with about 10 different string values. 7 of the them have really small counts so I want to group them as 'Other'. So I would usually have a statement like
CASE
WHEN "B" THEN "B"
WHEN "O" THEN "O"
WHEN "P" THEN "P"
ELSE "Other"
Rather than map every possible string value, how do I specify the main categories and have an else condition for everything else?
thanks.