Question: Create a new column with a 1 if the country's % Renewable value is at or above the median for all countries in the top 15, and a 0 if the country's % Renewable value is below the median.
My Solution:
medi = Top15['% Renewable'].median()
if Top15['% Renewable'] >= medi:
Top15['new col'] = 1
else:
Top15['new col'] = 0
Top15
Error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Help: Can someone please tell me why this error is coming?Click on this link to see the dataframe