0

I have a Dataframe where I need to find out how many unique id's that exists per url (which is another column in the dataframe).

The dataframe looks like this:

12333   google.com
13232   yahoo.com
12333   yahoo.com
12333   google.com

In this table the result would be:

google.com 1
yahoo.com 2

I've amongst other things tried this:

pdf.groupby(['url', 'id']).size().reset_index().rename(columns={0: 'count'})

which gives me this df:

google.com 12333 2
yahoo.com 13232 1
yahoo.com 13333 1

I'm just not sure how to get to the last step.

user16655
  • 1,901
  • 6
  • 36
  • 60

0 Answers0