bforsyth744 / intro-data-capstone-biodiversity

0 stars 0 forks source link

Redundant if #3

Open sen1 opened 6 years ago

sen1 commented 6 years ago

https://github.com/bforsyth744/intro-data-capstone-biodiversity/blob/9fc2b0c2dd140344a070aec6905743b795d0e931/Capstone_Option_2/biodiversity.py.html#L329

'Sheep' in x returns a boolean. So adding an extra if does not really gain you anything. You code works but inefficient.

 species['is_sheep'] = species.common_names.apply(lambda x: Sheep' in x) 
bforsyth744 commented 6 years ago

That's cool. Makes sense. Thanks. I'll remember that.