There are variations of this in the net but not quite what I am expecting. I have a dataframe like so:
+------+-------+------------+---------------+----------------+--------+---------+
|SEQ_ID|TOOL_ID|isfleetlevel|is_golden_limit|use_golden_limit|New_UL |New_LL |
+------+-------+------------+---------------+----------------+--------+---------+
|790026|9160 |0 |1 |0 |26.1184 |23.2954 |
|790026|13509 |0 |0 |1 |Infinity|-Infinity|
|790026|9162 |0 |0 |0 |25.03535|23.48585 |
|790026|13510 |0 |0 |1 |Infinity|-Infinity|
|790048|9162 |0 |0 |0 |33.5 |30.5 |
|790048|13509 |0 |0 |1 |Infinity|-Infinity|
|790048|13510 |0 |0 |0 |NaN |NaN |
|790048|9160 |0 |1 |0 |33.94075|30.75925 |
+------+-------+------------+---------------+----------------+--------+---------+
I want to replace the New_UL and New_LL values where the use_golden_limit is 1 with values where the is_golden_limit is 1 for each SEQ_ID. So, in this case, the expected result would be:
+------+-------+------------+---------------+----------------+--------+---------+
|SEQ_ID|TOOL_ID|isfleetlevel|is_golden_limit|use_golden_limit|New_UL |New_LL |
+------+-------+------------+---------------+----------------+--------+---------+
|790026|9160 |0 |1 |0 |26.1184 |23.2954 |
|790026|13509 |0 |0 |1 |26.1184 |23.2954 |
|790026|9162 |0 |0 |0 |25.03535|23.48585 |
|790026|13510 |0 |0 |1 |26.1184 |23.2954 |
|790048|9162 |0 |0 |0 |33.5 |30.5 |
|790048|13509 |0 |0 |1 |33.94075|30.75925 |
|790048|13510 |0 |0 |0 |NaN |NaN |
|790048|9160 |0 |1 |0 |33.94075|30.75925 |
+------+-------+------------+---------------+----------------+--------+---------+
Is this possible?
is_golden_limit= 1should not have more than one row. I have code to identify such cases to take care of them separately. However, that's a good question. In case it does have more than one row where it is =1, does it take the first value?