I have the following database:

enter image description here

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

enter image description here

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.

  • $\begingroup$ BTW the first image looks like confidential data, maybe you should delete it $\endgroup$ Feb 3, 2021 at 11:55
  • 1
    $\begingroup$ @DavidMasip No, no. It's fake! Gràcies! $\endgroup$
    – Arnau
    Feb 3, 2021 at 14:38
  • $\begingroup$ ok my bad, did I answer your question? $\endgroup$ Feb 3, 2021 at 15:49
  • $\begingroup$ @DavidMasip you did! thanks $\endgroup$
    – Arnau
    Feb 4, 2021 at 17:14

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.