ka-tya / codecademy

0 stars 0 forks source link

Boolean expressions #3

Open cyouh95 opened 6 years ago

cyouh95 commented 6 years ago

Alternatively, you could simplify the following line:

species['is_sheep'] = species.common_names.apply(lambda name: True if 'Sheep' in name else False)

to:

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

'Sheep' in name itself would resolve to either True or False, and that would be returned in the lambda function.