Skip to content

Instantly share code, notes, and snippets.

@sid321axn
Created August 19, 2020 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sid321axn/947f4c7d1bdff0f7ba34146dc421889f to your computer and use it in GitHub Desktop.
Save sid321axn/947f4c7d1bdff0f7ba34146dc421889f to your computer and use it in GitHub Desktop.
#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