To demonstrate how we can group data efficiently in pandas, let's first create a new column with the providers of email services. Here, we can use the trick for splitting columns that you're already familiar with:
# Creating new columb with the email service providers
clients['email_provider'] = clients['email'].str.split('@', expand = True)[1]
clients['email_provider'].head()
Now let's group the clients by state and email_provider:
# Grouping clients by state and email provider
clients.groupby('state')['email_provider'].value_counts()
We've now got a data frame that uses several levels of indexing to provide access to each observation (known as multi-indexing).