Menu

Post image 1
Post image 2
1 / 2
0

Python Performance Analysis

DEV Community·Deepak Prasad·24 days ago
#exawbBar
#use#python#pandas#performance#apply#using
Reading 0:00
15s threshold

When I first started using pandas for data analysis, I started using loops. However, loops are time consuming and so I started looking for alternatives and that is what I am trying to share with everyone. The apply() Method We can use apply with a lambda function. The performance of apply function depends on the content of the expression. Swifter apply() It is a combination of pandas apply (non-parallel) and dask apply (parallelized). Since swifter toggles between these two modes, it is faster than dask. Refer to the reference section for more detail. This is a third-party library which has to be installed before importing. Numpy vectorize() The vectorized function evaluates pyfunc over successive tuples of the input arrays like the Python map function, except it uses the broadcasting rules of numpy. The data type of the output of vectorized is determined by calling the function with the first element of the input. This can be avoided by specifying the otypes argument.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More