I'm sure the answer to this is simple - I just can't it for some reason.
I'd like to extract the URL Path from a DataFrame of URLs without using a for loop - as i'll be running this against 1M+ rows and loops are too slow.
from urllib.parse import urlparse
d = {'urls': ['https://www.example.com/ex/1','https://www.example.com/1/ex']}
df = pd.DataFrame(data=d)
df
df['urls'].apply(urlparse)
Above is where i'm at, which returns an object of all parts of the URL returned by urllib
The desired end result is a DataFrame like the below:
d = {'urls': ['https://www.example.com/ex/1','https://www.example.com/1/ex'], 'url_path': ['/ex/1', '/1/ex']}
If anyone knows how to solve this - i'd appreciate the help!
Thanks!