Split dataframe by category of one variable and the ocurrences for another variable

I have a dataset with several columns. Two of them (Patients ID and timepoint) are as follows:

ID | Timepoint
3  | Day1Hour0
3  | Day2Hour4
3  | Day3Hour0
4  | Day1Hour0
4  | Day2Hour4
4  | Day4Hour0 
6  | Day1Hour0
6  | Day2Hour4
6  | Day3Hour0

As you can see, the last time is different for some patients.
I want to split the dataset so I will have all the patients that has a Day4 timepoint in one side, and those with Day3 in other.
So I would get something like:

Data1
ID | Timepoint
3  | Day1Hour0
3  | Day2Hour4
3  | Day3Hour0
6  | Day1Hour0
6  | Day2Hour4
6  | Day3Hour0
Data2
4  | Day1Hour0
4  | Day2Hour4
4  | Day4Hour0 

Out of my head, you could use a row splitter node to split the Day 4 patient ids and then use those filtered ids and join them back to the original dataset to have the day 4 identified. Then you filter out those ids from the rest to get the 3 day patients
br

1 Like

Hi @RoyBatty296 , I put something basic for you that does what you are looking for.

The workflow looks like this:
image

Input data (same as yours):
image

Output:
Data1:
image

Data2:
image

Here’s the workflow: Split data by category.knwf (14.3 KB)

3 Likes

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