I have temperature data that looks like this:
Date State Temperature (F)
2018-10-6 AL 15
2018-10-7 AL 45
2018-10-8 AL 67
2018-10-9 AL 25
2018-10-10 AL 55
2018-10-11 AL 77
.
.
I'd like to give a conditional statement that calculates a simple subtraction that creates a new column like this:
if df[Temperature, i] < 65:
df[Calculation, i] = 65 - df[Temperature, i]
else:
df[Calculation, i] = 0
So the output would be:
Date State Temperature (F) Calculation
2018-10-6 AL 15 0
2018-10-7 AL 45 0
2018-10-8 AL 67 2
2018-10-9 AL 25 0
2018-10-10 AL 55 0
2018-10-11 AL 77 12
.
.
I'm not sure how to simply iterate over the column with this type of loop.
Is there an easy way to do this?