split years from one cell to multiple cell
HI,
I have one dataset and it contains the year ranges in one cell (1993-1996). I want to split each year into separate cells (1993,1994,1995,1996). Does anyone have an Idea suggest me.
Answers
-
Rushil09 Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered, Frontrunner 2022 Participant Posts: 17 Partner
Hi,
How exactly will the cells be laid out? in form of columns?
Can you sen the screenshot of what you want to do if i am getting this wrong.
-
AlexGo Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 18 Dataiker
If you want to use the visual recipe steps and you have a consistent format, you could do something like:
- Split the cell on '-',
- Use a formula such as "forRange(year_range_0,year_range_1, 1+1, v, v)"
- Unnest the array into separate columns
This gets the first and last year, takes all years between the first and the last, steps through each year and then applies a formula to it (in this case the formula is just returning the value).
You might have issues if the format is inconsistent though e.g. there's a single year. You would have to edit the formula step to include an 'if' to check for things like this.