0

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.

  • Does this answer your question? [Pandas: sum DataFrame rows for given columns](https://stackoverflow.com/questions/25748683/pandas-sum-dataframe-rows-for-given-columns) – Blake G Dec 06 '20 at 05:28

2 Answers2

2

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

0

Try

free_apps = data[data["price"] == 0.00]["prime_genre"]
free_apps.value_counts()
vdvivek
  • 16
  • 1
  • Thanks for taking the time to provide an answer to the question. Since there is often more than one answer provided, it usually helps the question asker by providing a short description of what your solution does and why it's best. – DaveL17 Dec 10 '20 at 12:23