I have a dataframe, called PORResult
, of daily temperatures where rows are years and each column is a day (121 rows x 365 columns). I also have an array, called Percentile_90
, of a threshold temperature for each day (length=365). For every day for every year in the PORResult
dataframe I want to find out if the value for that day is higher than the value for that day in the Percentile_90
array. The results of which I want to store in a new dataframe, called Count
(121rows x 365 columns). To start, the Count
dataframe is full of zeros, but if the daily value in PORResult
is greater than the daily value in Percentile_90
. I want to change the daily value in Count to 1.
This is what I'm starting with:
for i in range(len(PORResult)):
if PORResult.loc[i] > Percentile_90[i]:
CountResult[i]+=1
But when I try this I get KeyError:0. What else can I try?