Skip to content

Instantly share code, notes, and snippets.

@sid321axn
Created August 18, 2020 16:14
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/35406b5a7c6b70b9666c44776ace28ce to your computer and use it in GitHub Desktop.
Save sid321axn/35406b5a7c6b70b9666c44776ace28ce to your computer and use it in GitHub Desktop.
from urllib.parse import urlparse
def no_of_dir(url):
urldir = urlparse(url).path
return urldir.count('/')
df['count_dir'] = df['url'].apply(lambda i: no_of_dir(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment