Skip to content

Instantly share code, notes, and snippets.

@sid321axn
Created August 19, 2020 09:32
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/49a513c1bd39429ea2fd2bc26c210910 to your computer and use it in GitHub Desktop.
Save sid321axn/49a513c1bd39429ea2fd2bc26c210910 to your computer and use it in GitHub Desktop.
from tld import get_tld
import os.path
#Length of Top Level Domain
df['tld'] = df['url'].apply(lambda i: get_tld(i,fail_silently=True))
def tld_length(tld):
try:
return len(tld)
except:
return -1
df['tld_length'] = df['tld'].apply(lambda i: tld_length(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment