-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
02: Filtering and Sorting/Chipotle, Step-4 & 5 #65
Comments
I agree with you. I think the answer provide is simply wrong. |
I agree too. However, to get the number of products costing more than $10.00, I believe you could use a simpler command: |
I came up with the same issue. The question needs to be reconsidered, or the proposed solution changed. I believe the number of unique products with a price higher than 10 is 31. I use this code, after changing the column to float: |
@bromero26 I get the same answer as you using a slightly more verbose method:
But all of those high prices are caused by extras or specific configurations. If you stick to the basics, any item can be had for less than $10:
The question is not well-formed. It could be asking:
|
@rahimnathwani I agree with you, the question is not well-formed. Still, I believe that @matiascalderini suggestion is correct since price vs quantity seems quite linear. Check using water bottles as an example: (
chipo.query('item_name == "Bottled Water"')[['quantity', 'item_price']]
.groupby('quantity')
.agg(['mean', 'std'])
.item_price
.reset_index()
.plot(x='quantity', y='mean', yerr='std', kind='scatter')
) Normalizing the cost I get these values: chipo['price_per_item'] = chipo.item_price/chipo.quantity
A1 = chipo.query('price_per_item > 10').item_name.nunique()
A2 = (chipo.groupby('item_name').price_per_item.min()>10).sum()
chipo['name_with_variants'] = chipo.item_name+chipo.choice_description
A3 = (chipo.groupby('name_with_variants').price_per_item.min()>10).sum()
print(f'A1:{A1}, A2:{A2}, A3:{A3}') A1:25, A2:0, A3:707 |
Hi everyone, thank you for the comments and feedback. I agree that this question is not so clear too. Some clarifications:
Example: Canned Soda costs $1.09. If I buy 10 sodas, the line will show up $10.90, which is greater than $10, but that doesn't mean that the product Canned Soda costs more than $10. That is the reason that quantity needs to be considered for this exercise.
Example: order _id | quantity | item_name | choice_description | item_price "Chicken Burrito" is the "main" product but depending on the additional items it will cost more or less than $10, so to simplify take the combination Considering that what is your suggestion? Send me a PR! 😉 |
In the getting and knowing your data part ,the url donnot work.what should I do? |
In 02-Filtering_and_Sorting/Chipotle, step 4 and 5,
chipo['item_price'] = chipo['item_price']/chipo['quantity']
chipo['quantity'] = 1 #Dividing item_price by quantity, therefore let quantity be 1
chipo.drop_duplicates(['item_name'], keep='first', inplace=True)
chipo.sort_values(by='item_price', ascending=False, inplace=True)
display(chipo[['item_name', 'item_price']])
I'm also a beginner at Pandas, please let me know about any stupid thing that I missed. Thanks.
The text was updated successfully, but these errors were encountered: