I have a df which contains a column of urls, when these urls are visited, you will be redirected to the real urls. I need to loop through all the urls one by one and get their corresponding redirect url back like this:
def get_redirect_url(url):
#some code
return redirect_url
df.url.apply(get_redirect_url)
If the df has 100 lines of data, it takes about 3 minutes for the apply method to finish. But sometimes, I may have a df with 5000+ lines which takes an hour to finish. I wonder if there is anyways to speed up the operation.
Is it possible to have multiple threads running at the same time to speed up?
Update
The solution shared by @GiantsLoveDeathMetal works!