0

This is the get_tld code:

from tld import get_tld
res = get_tld("http://toystory.disney.com/toy-story", as_object=True)
print(res.domain)

I'd like to apply this to an entire column in a dataset. I'm only interested in the top level domain and not the subdomain nor the suffix.

Mike D
  • 23
  • 3

1 Answers1

1

Use Series.apply()

df['tld'] = df['homepage'].apply(lambda x: get_tld(x, as_object=True).domain)
azro
  • 53,056
  • 7
  • 34
  • 70