This community-built FAQ covers the “What cuisines does FoodWheel offer?” 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 What cuisines does FoodWheel offer?
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 (
) 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 (
) below!
Agree with a comment or answer? 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!
What is cuisine.values?
cuisine_counts = restaurants.groupby('cuisine').name.count().reset_index()
print(cuisine_counts)
cuisines = cuisine_counts.cuisine.values
print(cuisines)
And how come I cannot print it?
DataSeries.values is a list, DataFrame is a list of list (each list as 1 row). Both of them are Numpy arrays.
I think another valid answer is cuisine_counts.cuisine.tolist()
. (Unless someone could point out the flaw in this method). However when I input it, Codecademy throws an absurd error saying it should be a list (it is).
3 Likes
I also thought the error message which Codecademy throwed was strange. In addition, according to the Pandas documentation for the .values
, it is recommended to use .array
or .to_numpy()
instead, in the current version.
I’ve tried several ways to turn a Series into a list or an array, but strictly speaking, among the following ways it returns a list only if we use list()
function or .to_list()
method.
cuisines = cuisine_counts.cuisine.values
print(type(cuisines))
# <class 'numpy.ndarray'>
cuisines = cuisine_counts.cuisine.array
print(type(cuisines))
# <class 'pandas.core.arrays.numpy_.PandasArray'>
cuisines = cuisine_counts.cuisine.to_numpy()
print(type(cuisines))
# <class 'numpy.ndarray'>
cuisines = list(cuisine_counts.cuisine)
print(type(cuisines))
# <class 'list'>
cuisines = cuisine_counts.cuisine.to_list()
print(type(cuisines))
# <class 'list'>
2 Likes
I am also confused by this. I tried:
cuisines = [i for i in cuisine_counts.cuisine]
This produces a list but the excercise would not accept it.
I think it’s just a CodeCademy thing. I’ve encountered that the platform accepts only a specific kind of answer (a little bit lazy if you ask me).
As we all know, most of the time in python there are several ways around a problem, which one we select (and how elegant or efficient it is) is up to us.
I also used the .to_list( ) method, returning the same error. Then i just used the .value method just to pass the checkpoint, then I deleted it and used .to_list( ) again (yeah, I’m that stubborn lol), which returned no problem for the rest of the checkpoints.
Cheers! 