So I have a df that has a column full of domains. So for example I have records like this
common_name
www.amazon.com
amazon.com
subexample.amazon.com
walmart.en
walmart.uk
michigan.edu
I want to use python to extract anything before the last . but before the 1st period if there is one. So the results would look like this.
common_name
amazon
amazon
amazon
walmart
walmart
michigan
I found some examples of this here but it looks like it was an operator on a string and it was anything before the certain character not between them. The string operator may take awhile to run, so wondering if there is a function using pandas on the whole df by chance?