Thanks for looking into my questions! To sum up, I run the code in a loop ("for year in 2019 to 2028"), in each iteration, I have a constant value "temperature" from another dataframe that only changes with year. I am trying to modify the value of a column called "forecast" based on that. For example, in the first iteration as year is 2019, I want forecast = temperature, and only the rows with year=2019 would be changed, and so on with the following years
I tried to use if to set the condition, but there is error.
for year in range (2019,2029):
temperature=(
df_Ckt.loc[df_Ckt['Circuit Key']==circuit,year].reset_index(drop=True))
if df['year'] == year:
df['forecast_year']=year_value
The errors are as below:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I know that I can avoid using if-else using functions like loc, but does loc only returns the value in a dataframe instead of constant values?