Jul-27-2022, 06:59 PM
(This post was last modified: Jul-27-2022, 07:03 PM by Led_Zeppelin.)
Here is the original if-then-else statement
At first, I thought that the unexpected Error (the interpreter said my machine-status columns had NANs and then it failed. i thought it was confusing a 0 as a number for 0 as a symbol. I did have a lot of NAN's. I did not know what o do about this. That was not the case.
I fact the if-then-else statement was clearly wrong.
So, I corrected the if-then-else statement to this:
Respectfully,
LZ
df2["machine_status"] = df2["machine_status"].map( lambda x: 0 if x == "NORMAL" else 1 if x == "BROKEN" else 2 if x == "BROKEN" else np.NaNI am changing strings such a NORMAL, BROKEN or RECOVERING to numbers. The numbers are O if NORMAL and 1 if BROKEN or RECOVERING.
At first, I thought that the unexpected Error (the interpreter said my machine-status columns had NANs and then it failed. i thought it was confusing a 0 as a number for 0 as a symbol. I did have a lot of NAN's. I did not know what o do about this. That was not the case.
I fact the if-then-else statement was clearly wrong.
So, I corrected the if-then-else statement to this:
df2["machine_status"] = df2["machine_status"].map( lambda x: 0 if x == "NORMAL" else 1 )And then my program worked as I wanted.
Respectfully,
LZ