(Apr-24-2022, 06:36 AM)shantanu97 Wrote: I recommend everyone to check attached python script as it will give you an idea how I written my python code and logic.Ahh what the .... 2238 lines of code 😵
This is not all how you work with Pandas DataFrame.
Clean up data before and when in Pandas work on whole DataFrame with
vectorized
and build in solutions.So
loop
or build in iterrows()
should only be used when needed,in most cases not at all.People think in Python way where loop is common to us,Pandas need a different approach.
Some more info in Optimizing Pandas
Quote:Perhaps the most important rule is toavoid using loops in Pandas
code.
Looping over a Series or a DataFrame processes data one item or row/column at a time.
Instead, operations should bevectorized
.
This means an operation should be performed on the entire Series or DataFrame row/column.
Developers should think of all operations as matrix computations that can be parallelized