Recode row values for a given column

Inside a dataframe I have a column as follows:

TIME
20MIN
20MIN
40MIN
40MIN
1H
1H
2H
2H
8H
8H
1D
2D
10D
20D

I want to create another column from this one that has only the days.
So if it ends with MIN or H, I would get one, if it ends with D, I would get the previous number.
In the end I would get something like this:

TIMEder
1
1
1
1
1
1
1
1
1
1
1
2
10
20

Here you go:
Step 1: Replace everthing that doesn’t end with a D with 1
Step 2: Remove the “D”
recode_duration
recode_duration.knwf (15.8 KB)

3 Likes

Hello @RoyBatty296

You can start by ‘Regex Split’ node
(\d+)(.*)

Then a ‘Rule Engine’ similar to @Thyme 's approach

BR

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.