0
$\begingroup$

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.

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

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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