fabriciodisalvo / biodiversity_codecademy

BIodiversity Capstone Project for codecademy.com
0 stars 0 forks source link

Simplify boolean expressions #2

Open cyouh95 opened 6 years ago

cyouh95 commented 6 years ago

You could simplify this line:

https://github.com/fabriciodisalvo/biodiversity_codecademy/blob/8cdccdb15906229f11a9467d480a1143575dcc57/biodiversity.py#L311

to:

species['is_sheep'] = species.common_names.apply(lambda x: 'Sheep' in x)

'Sheep' in x itself would resolve to either True or False, which would be returned in the lambda function.