0

After some operations I have a series that i got after grouping by phone number and counting different calls. I need to count the phone numbers that have an equal number of calls. I mean, if there is 5 people who made 3 calls I need to get a series or a dataframe looking like:

num_calls 
3    5
1    100
...

My series now looks like

phone_num 
89248089190  5
48048102481  6 
12948148014  2
14091404108  5
nutcracker
  • 101
  • 1
  • 9

2 Answers2

1

.value_counts() does that thing

nutcracker
  • 101
  • 1
  • 9
1

For creating a DataFrame I did the following:

numbers = [89248089190, 48048102481, 12948148014, 14091404108]
calls = [5, 6, 2, 5]

df = pd.DataFrame({'numbers': numbers,
                   'calls': calls})

I then groupby 'calls'

num_calls = df.groupby('calls')

And then count the number of occurrences

count = num_calls.count()


        numbers
calls   
2       1
5       2
6       1