I completed and submitted the final graded lab for module 2. I received 0 points for ex5 product counts. I believe I did it correctly, and when I check my answer against the expected answer, they are the same, except for the order. The result I receive when I run the cell is:
product_name
HAND WARMER OWL DESIGN 8
HAND WARMER BIRD DESIGN 8
CHRISTMAS CRAFT LITTLE FRIENDS 7
HAND WARMER RED RETROSPOT 7
HAND WARMER SCOTTY DOG DESIGN 6
Name: count, dtype: int64
This is the expected result:
HAND WARMER BIRD DESIGN 8
HAND WARMER OWL DESIGN 8
HAND WARMER RED RETROSPOT 7
CHRISTMAS CRAFT LITTLE FRIENDS 7
HAND WARMER SCOTTY DOG DESIGN 6
Name: count, dtype: int64
Is the order important? I don’t understand how I can change the order of this list if multiple items have the same value_count.
Hello, @pfister75,
Welcome to this community!
First, I think the order matters to the grader. Then, though value_counts()
sorts the result by their counts, I believe it does not secondarily sort them by their names, which means that if, to an extreme, all 'HAND WARMER OWL DESIGN'
come before 'HAND WARMER OWL DESIGN'
, then that will be the same in the result of value_counts()
.
I hope you have gotten some idea on how to modify exercise 5 to reverse their order, but since that’s not instructed, such modification should not be necessary. Up to exercise 5 there should be only two dataframes which you can apply value_counts()
to, try both and see if you can make sense of the results given my explanation in the first paragraph of this post

Cheers,
Raymond
1 Like
I tried running count_values on both the dfs I’ve created until ex5 and they both give the same order of answer. I then asked the ai for help and it had me use sort_index and sort_values with a mergesort on the data_counts. Trying different ascending and descending orders, I can get the two 8 counts to switch to the correct order, but then the 7 counts also switch. So nothing I’m trying is giving me the correct order. I resubmitted my lab with the 8 counts in the correct order, but the 7 counts out of order and I received no points for exercise 5 again. I passed the lab with a 90, so I can move on, but not knowing how to fix this will continue to bother me.
1 Like
Hi Carlos, and welcome to the Forum! Can you send me your notebook via direct message? You can click on my name then the blue Message button. We’ll investigate and update the grader if necessary. Thanks!
Hi Carlos! The issue is with the use of value_counts()
. You should first get the desired column then use this method. See how it is used in the lectures and in the third practice lab of this module. Hope this helps!
1 Like