Skip to content

Fix: Remove extra "order_id" sum and make output clean for "Most Popular Item".#183

Open
IVDOT80 wants to merge 2 commits into
guipsamora:masterfrom
IVDOT80:fix01
Open

Fix: Remove extra "order_id" sum and make output clean for "Most Popular Item".#183
IVDOT80 wants to merge 2 commits into
guipsamora:masterfrom
IVDOT80:fix01

Conversation

@IVDOT80

@IVDOT80 IVDOT80 commented Nov 2, 2025

Copy link
Copy Markdown

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

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()
c = c.sort_values(['quantity'], ascending=False)
c.head(1)
image

@hannanhtang

hannanhtang commented Jan 3, 2026 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants