How to convert boolean value of a column to other column value (row wise) in a data frame?

employee_id date time type Login Logout 0 1 03-01-2018 09:00:00 Login True False 1 1 03-01-2018 10:11:00 Logout False True 2 1 03-01-2018 12:30:00 Logout False True 3 1 03-01-2018 13:00:00 Login True False 4 1 03-01-2018 15:00:00 Logout False True

After trying many different techniques like np.where(), .replace() and pivot methods the result doesn't match as per the below test case. What is missing here? Is there any simpler solution to resolve such problems ?

employee_id date Login Logout 1 3/1/2018 9:00:00 10:11:00 1 3/1/2018 12:30:00 1 3/1/2018 13:00:00 15:00:00 1 3/1/2018 16:00:00
1 3/2/2018 9:50:00 1 3/2/2018 10:30:00
1 3/2/2018 13:00:00 16:10:00

Desired Result



Read more here: https://stackoverflow.com/questions/66266446/how-to-convert-boolean-value-of-a-column-to-other-column-value-row-wise-in-a-d

Content Attribution

This content was originally published by gk_stack at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: