I am trying to iterate through a Pandas Series.
If a value in the column '% Renewable' is greater than the median for the '% Renewable' column, the value should be assigned to 1 in a new column 'HighRenew'. Otherwise the value should remain as it is.
The value of each item in the new series 'HighRenew' should change according to whether the condition is met.
for value in Reducedset['% Renewable']:
if value >= Reducedset['% Renewable'].median():
Reducedset['HighRenew'] = 1
else:
Reducedset['HighRenew'] = value
However, I only want to amend the specific value/element in the series and not the entire series when the condition is met by the if loop.
Could anybody give me any advice?