Sep-08-2022, 12:42 PM
I am using the following statement in my program
I would like to use the same logic code on my time period where I say if morning insert 1 in place or morning and if afternoon insert 2 in place of morning and if evening insert 3 in place of evening and if night insert 4 in place of night. I tried that and I got an error.
Th error said expected else after if statement. Well in my current situation, I have four not two conditions. Thus, there will be three more if statements and else follows the last if statement.
But the interpreter does not like it and it gives me an error.
How can I fix this.
The data that I am trying to change is in a dataframe like this
time period
night
morning
afternoon
evening
That is what I am applying my python 3 code to. How do I write the code?
Respectfully,
LZ
df2["machine_status"] = df2["machine_status"].map( lambda x: 0 if x == "NORMAL" else 1 )This clearly refers to the machine status in the program. I am changing the values normal and broken to numeric values. If normal, then use 0 else use 1.
I would like to use the same logic code on my time period where I say if morning insert 1 in place or morning and if afternoon insert 2 in place of morning and if evening insert 3 in place of evening and if night insert 4 in place of night. I tried that and I got an error.
Th error said expected else after if statement. Well in my current situation, I have four not two conditions. Thus, there will be three more if statements and else follows the last if statement.
But the interpreter does not like it and it gives me an error.
How can I fix this.
The data that I am trying to change is in a dataframe like this
time period
night
morning
afternoon
evening
That is what I am applying my python 3 code to. How do I write the code?
Respectfully,
LZ