Fix: Remove extra "order_id" sum and make output clean for "Most Popular Item".#183
Open
IVDOT80 wants to merge 2 commits into
Open
Fix: Remove extra "order_id" sum and make output clean for "Most Popular Item".#183IVDOT80 wants to merge 2 commits into
IVDOT80 wants to merge 2 commits into
Conversation
|
unsubscribe
At 2025-11-02 20:56:54, "Mahdi-Mahmoudnazari" ***@***.***> wrote:
Description
Problem:
The code for finding the most popular item used in the solution:
c=chipo.groupby('item_name')
c=c.sum()
c=c.sort_values(['quantity'], ascending=False)
c.head(1)
image.png (view on web)
This caused problems:
It added all columns, including 'order_id'. Even though the expected answer shows an 'order_id' column, it only displays the sum of order Ids, which has no real meaning.
The result doesn't match the expected output in the solution.
Fixed:
The code now only uses 'item_name' and 'quantity' before grouping and summing:
c=chipo[['item_name','quantity']].groupby('item_name')
c=c.sum()
image.png (view on web)
You can view, comment on, or merge this pull request online at:
#183
Commit Summary
20ce83e Fixing 01> Chipotle> Step 9
d485cfd Fixing 01> Chipotle> Step 10
File Changes
(1 file)
M01_Getting_&_Knowing_Your_Data/Chipotle/Exercise_with_Solutions.ipynb (89)
Patch Links:
https://github.com/guipsamora/pandas_exercises/pull/183.patch
https://github.com/guipsamora/pandas_exercises/pull/183.diff
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem:
The code for finding the most popular item used in the solution:
This caused problems:
Fixed:
The code now only uses 'item_name' and 'quantity' before grouping and summing: