FAQ: Project: Board Slides for FoodWheel - FoodWheel: Let the Food Choose For You

This community-built FAQ covers the “FoodWheel: Let the Food Choose For You” exercise from the lesson “Project: Board Slides for FoodWheel”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

FAQs on the exercise FoodWheel: Let the Food Choose For You

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Why do I need to use “.reset_index()” on question 5 but not on question 4 of the lesson.

2 Likes

Why do we need to apply the dot operator to ‘name’ on q5? When I do restaurants.groupby('cuisine').count().reset_index() I get the same thing but it marks it incorrect

Yes with your Command you will getting the same output but its counting all the columns

      cuisine  id  name  neighborhood
0    American  10    10            10
1     Chinese  11    11            11
2     Italian   8     8             8
3    Japanese   4     4             4
4      Korean   3     3             3
5       Pizza   4     4             4
6  Vegetarian   4     4             4

We need to specify

name

as we only want to count that columns value…instead of counting all others also.

will give only names column

      cuisine  name
0    American    10
1     Chinese    11
2     Italian     8
3    Japanese     4
4      Korean     3
5       Pizza     4
6  Vegetarian     4

the correct syntax for writing this command is

dataframe_name.groupby('col1').col2.any_aggregate_command.reset_index()

reset_index() - return index with order

4 Likes

Since question 4 asks for giving a number, .reset_index() isn’t needed at all. But for question 5, I had the same question. My first answer for question 5 was

cuisine_counts = restaurants.groupby('cuisine').id.count()

and cuisine_counts was assigned the following Series:

cuisine
American      10
Chinese       11
Italian        8
Japanese       4
Korean         3
Pizza          4
Vegetarian     4

Here cuisine is the index (not a column).

On the other hand, the expected answer seems to be, for example:

cuisine_counts = restaurants.groupby('cuisine').id.count().reset_index()

In this case, the following DataFrame will be assigned to cuisine_counts:

      cuisine  id
0    American  10
1     Chinese  11
2     Italian   8
3    Japanese   4
4      Korean   3
5       Pizza   4
6  Vegetarian   4

cuisine is one of the columns. So probably the required one was a DataFrame with cuisine as one of its columns. I think the question statement was unclear in this point.

cuisine_counts = restaurants.groupby(‘cuisine’).name.count().reset_index()

I am not sure what the label should be formatted as. I tried cuisine_labels = restaurants[‘cuisine’] but I keep receiving an ‘label must be length of x’ error when I try to create the pie chart.

Can someone tell me what I’m doing wrong?