Skip to content

Conversation

@IVDOT80
Copy link

@IVDOT80 IVDOT80 commented Nov 2, 2025

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

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.

1 participant