Jul-05-2022, 01:29 PM
(This post was last modified: Jul-05-2022, 01:30 PM by Led_Zeppelin.)
I need to convert a column which indicates machine status (normal, broken or recovering) to a numeric representation. This seems easy enough, but I want to do it in one line of python 3 code if possible. It would be something like this.
I found this online, and I want to use it because it is only one line.
The pump has two states in the final version: normal or broken; broken includes recovering because the pump is still not functional when recovering.
I believe that this one line of python code can do it for all 220320 values in the column.
My question is, is it on the right track? Is there an even easier way to do it?
Any help appreciated.
Respectfully,
LZ
sensor_data['label'] = sensor_data['machine_status'].map(lambda label: 0 if label == 'NORMAL' else 1).
I found this online, and I want to use it because it is only one line.
The pump has two states in the final version: normal or broken; broken includes recovering because the pump is still not functional when recovering.
I believe that this one line of python code can do it for all 220320 values in the column.
My question is, is it on the right track? Is there an even easier way to do it?
Any help appreciated.
Respectfully,
LZ