Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Data Science by (17.6k points)

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

1 Answer

0 votes
by (41.4k points)

For creating the DataFrame, you can do this :

numbers = [89248089190, 48048102481, 12948148014, 14091404108]

calls = [5, 6, 2, 5]

df = pd.DataFrame({'numbers': numbers,

                   'calls': calls})

After that groupby 'calls'

num_calls = df.groupby('calls')

Count the number of occurrences

count = num_calls.count()

        numbers

calls   

2       1

5       2

6       1

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 31, 2019 in Data Science by sourav (17.6k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...