I am using the following code to expand the shortened URLs in a column of a very large dataframe. It is extremely slow. How can I do the same thing in a more efficient way?
Thanks!
Here is my code :
from __future__ import absolute_import
import requests
trib=df[df['url'].str.contains('https://trib.al/',na=False)]
expand=trib['url'].tolist()
for trib in expand:
r = requests.get(trib)
df['url']=df['url'].str.replace(trib, r.url, regex=False)