asairi nava
asairi nava

Reputation: 19

Count the values in a list

The instruction is this:

Which genre is most likely to contain free apps?

First, filter data where the price is 0.00. Assign the filtered data to a new variable called free_apps. Then count the values in free_apps. Your code should return:

Games                2257
Entertainment         334
Photo & Video         167
Social Networking     143
Education             132
Shopping              121
Utilities             109
Lifestyle              94
Finance                84
Sports                 79
Health & Fitness       76
Music                  67
Book                   66
Productivity           62
News                   58
Travel                 56
Food & Drink           43
Weather                31
Navigation             20
Reference              20
Business               20
Catalogs                9
Medical                 8
Name: prime_genre, dtype: int64

But trying to apply functions all I get are errors or a count like this:

free_apps = data[data["price"] == 0.00]
free_apps.count_values()

AttributeError: 'DataFrame' object has no attribute 'count_values'

or

free_apps = data[data["price"] == 0.00]
free_apps = free_apps.count()
free_apps

id                  4056
track_name          4056
size_bytes          4056
price               4056
rating_count_tot    4056
rating_count_ver    4056
user_rating         4056
user_rating_ver     4056
prime_genre         4056
dtype: int64

what I try to do to obtain the count of the values ​​for each of the genres that has a price equal to 0.00, but i don't get it.

Upvotes: 0

Views: 76

Answers (2)

Adán H Baena
Adán H Baena

Reputation: 66

The function you are looking for is value_counts for pd.Series and count for pd.DataFrame.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.count.html

Upvotes: 2

vdvivek
vdvivek

Reputation: 16

Try

free_apps = data[data["price"] == 0.00]["prime_genre"]
free_apps.value_counts()

Upvotes: 0

Related Questions