Question: Question 1 . 5 . Assign the name by _ content to a DataFrame which counts the number of apps per 'Content Rating', indexed by

Question 1.5. Assign the name by_content to a DataFrame which counts the number of apps per 'Content Rating', indexed by 'Content Rating'.
Hint: To keep only certain columns in a DataFrame, call .get with a list of the names of the columns you want to keep.
In[72]:
by_content = apps.get(['Content Rating']).groupby('Content Rating').count()
by_content
Out[72]:
Content RatingAdults only 18+EveryoneEveryone 10+Mature 17+TeenUnrated
In[71]:
grader.check("q1_5")
Out[71]:
q1_5
results:
q1_5-1
result:
Test case passed!
q1_5-2
result:
Test case passed!
q1_5-3
result:
Trying: by_content.get(by_content.columns[0]).index[0]== 'Adults only 18+' Expecting: True ********************************************************************** Line 1, in q1_52 Failed example: by_content.get(by_content.columns[0]).index[0]== 'Adults only 18+' Exception raised: Traceback (most recent call last): File "/opt/conda/lib/python3.9/doctest.py", line 1336, in __run exec(compile(example.source, filename, "single", File "", line 1, in by_content.get(by_content.columns[0]).index[0]== 'Adults only 18+' File "/opt/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 5320, in __getitem__ return getitem(key) IndexError: index 0 is out of bounds for axis 0 with size 0
q1_5-4
result:
Trying: by_content.get(by_content.columns[0]).iloc[0]==3 # There are 3 apps with Content Rating 'Adults only 18+' Expecting: True ********************************************************************** Line 1, in q1_53 Failed example: by_content.get(by_content.columns[0]).iloc[0]==3 # There are 3 apps with Content Rating 'Adults only 18+' Exception raised: Traceback (most recent call last): File "/opt/conda/lib/python3.9/doctest.py", line 1336, in __run exec(compile(example.source, filename, "single", File "", line 1, in by_content.get(by_content.columns[0]).iloc[0]==3 # There are 3 apps with Content Rating 'Adults only 18+' File "/opt/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 5320, in __getitem__ return getitem(key) IndexError: index 0 is out of bounds for axis 0 with size 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!