Access keys of pandas dataframe when using groupby

I have the following database:

And I would like to know how many times a combination of BirthDate and Zipcode is repeated throughout the data table:

Now, my question is: How can I access the keys of this output? For instance, how can I get Birthdate=2000101 ZipCode=8002, for i = 0?

The problem is that this is a 'Series' object, so I'm not able to use .columns or .loc here.

Topic groupby dataframe jupyter ipython pandas

Category Data Science


You may use

df.groupby(['BirthDate', 'ZipCode']).size().reset_index().rename(columns={0: 'n'})

and now you have a data frame that you can easily manipulate.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.