0

I am trying to create a boolean mask so that when a value goes over a certain number it records '1' and 0 if it doesn't. This is the df.

Country              % Renewable
China                19.75
United States        11.57
Japan                10.23
United Kingdom       10.60
Russian Federation   17.29
Canada               61.95
Germany              17.90
India                14.97
France               17.02
Italy                33.67
Spain                37.97
Australia            11.81
Brazil               69.65
Turkey               28.54
Norway               97.64

This is the code I have used:

Top15['HighRenew'] = [1 if (Top15['% Renewable'] == 17) else 0 for i in range(len(Top15))]

However, when I use that it throws this error:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Any on how I can fix this?

Many thanks

Frank Jimenez
  • 319
  • 1
  • 7

0 Answers0