I have a column in my df with year values as INT but some values are 0. I'm trying to run a for loop to keep the 0 values but replace the year values with a calc (i.e 2020 - value in column). So far I have:
for (i, item) in enumerate(housing['YrRenovated']):
if item > 0:
housing['YrRenovated'][i] = 2020 - item,
else:
housing['YrRenovated'] = 0,
It runs but the max value in the column is 0 when it should be like 45