edebroux / intro-data-capstone-musclehub

0 stars 0 forks source link

redundant if #2

Open sen1 opened 6 years ago

sen1 commented 6 years ago

https://github.com/edebroux/intro-data-capstone-musclehub/blob/6ad8ddd4072ae81cf67414d0ddd68e05383fe39e/Capstone%20Project%202%20De%20Broux/biodiversity.py#L171

x == 'No Intervention' returns a boolean output. So adding another if statement does not make much sense. Although you would want the opposite of x == 'No Intervention', so just do x != 'No Intervention':

 species['is_protected'] = species.conservation_status.apply(lambda x: x != 'No Intervention') 

even a better way is this:

species['is_protected'] = species.conservation_status != 'No Intervention'