How to change row values conditionally for different rows

I have a dataframe with columns as follows:

Patient   Timepoint Val1 Val2
243         Day1         12   ?
243         Day2         23   23

For the patient 243 I want to change the val1 at day1 for the val2 at day 2.

In rule engine would be something like

$Patient$ LIKE "243" AND $Timepoint$ LIKE "Day1" => $Val2$ at Day2
TRUE => $Val1$

Of course you can’t do this with rule engine.
Wondering if it would be possible with a string manipulation

Hi Roy,

As far as I know you cannot to this if you don’t have all the information in the same row.

If your day information is always sequential, perhaps the node Lag Column can help you to retrieve the Val1 and Val2 from Day2 to Day1 and from there build your rule engine formula.

1 Like

Hi @RoyBatty296,

You can resolve this in multiple ways but the most adequate solution really depends on what your full data source is looking like and other scenario’s you might encounter. This is quite a narrow view.

For example; does each patient always only have two days throught the entire dataset? In that case the Missing Values nodes can be used. What should be done whenever a patient has multiple days (I suspect you are considering a time frame like a week/month) without a value, what should happen then?

1 Like

missing value or join with duplicate row filter come to my mind. I agree with @ArjenEX

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