If you want to have faster pandas apply when working with large data, try swifter. In the code above, I compared the speed of pandas apply and the speed of swifter apply using the California housing dataset of 20640 rows.
Using swifter apply is 23.56 times faster than Pandas apply! This ratio is calculated by taking the average run time of each method after 100 experiments.
To use swifter, simply add .swifter
before .apply
. Everything else is the same.
You can find swifter here.