Created
August 19, 2020 09:29
-
-
Save sid321axn/947f4c7d1bdff0f7ba34146dc421889f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Importing dependencies | |
from urllib.parse import urlparse | |
from tld import get_tld | |
import os.path | |
#First Directory Length | |
def fd_length(url): | |
urlpath= urlparse(url).path | |
try: | |
return len(urlpath.split('/')[1]) | |
except: | |
return 0 | |
df['fd_length'] = df['url'].apply(lambda i: fd_length(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment