Input df
ID Date TAVG TMAX TMIN
1 01-01-2020 26 21
2 01-01-2020 15 16
3 01-01-2020 25 29 18
1 02-01-2020 16 16
2 02-01-2020 26 20
.....
The code I am using
for index, row in df.iterrows():
if [(row["TMIN"].isnull()) & (row["TAVG"].notnull()) & (row["TMAX"].notnull())]:
row["TMIN"] = (2 * row["TAVG"]) - row["TMAX"]
if [(row["TMAX"].isnull()) & (row["TMIN"].notnull()) & (row["TAVG"].notnull())]:
row["TMAX"] = (2 * row["TAVG"]) - row["TMIN"]
if [(row["TAVG"].isnull()) & (row["TMIN"].notnull()) & (row["TMAX"].notnull())]:
row["TAVG"] = (row["TMIN"] + row["TMAX"]) / 2
When I run this, I get the below error:
if [(row["TMIN"].isnull()) & (row["TAVG"].notnull()) & (row["TMAX"].notnull())]:
AttributeError: 'float' object has no attribute 'isnull'
How to fix this? Any alternate way to achieve the same result?