I have a dataframe with a column named 'Temperature'
data = {'Day': [1,2,3,4],
'Temperature': [20,30,40,50]
}
Now, I don't want the temperature digit but to assign '1' to the cell where Temperature is within the range of 25 to 45. If it is not, I will assign 0 to it.
My desired dataframe is
data = {'Day': [1,2,3,4],
'Temperature': [0,1,1,0]
}
I have a boolean mask like below:
df[(df['Temperature']<=45) & (df['Temperature']>=25)]
How to use Boolean mask to achieve this? Or, What is the best way to do this?
Thank you.