What to replace loops and nested if sentences with in order to speed up Python code?
问题 How can I avoid for loops and nested if sentences and be more Pythonic? At first glance this may seem like a "please do my all of my work for me" question. I can assure you that it is not. I'm trying to learn some real Python, and would like to discover ways of speeding up code based on a reproducible example and a pre-defined function. I'm calculating returns from following certain signals in financial markets using loads of for loops and nested if sentences. I have made several attempts,