mercredi 4 juillet 2018

Python „stack overflow” (104 if statements). Is def(x) the only solution to optimise code?

Today have tried to check files with path directory name. Previously it worked, until I tried to create 104 if/else statements.

How to dispose of this overflow error? More specific question: Does def(x) for several checks the only one solution to optimise such cases in Python?enter image description here!

data['path'].apply( lambda path: 'hotdog' if '/hotdog/' in path Else ‘hotdog2’ if ‚’/hotdog2/’ in path Else ... Else’hotdog104’ if ... else 'nothotdog' ) I’ve done similar to this...

Aucun commentaire:

Enregistrer un commentaire