jmbejara / comp-econ-sp19

Main Course Repository for Computational Methods in Economics (Econ 21410, Spring 2019)
48 stars 26 forks source link

HW 2, chipotle (# 19) #13

Closed henryli78 closed 5 years ago

henryli78 commented 5 years ago

The question statement is:

  1. Select and return the rows corresponding to the Barbacoa Bowl. Give two reasons why the item price might vary.

I gave the answer

One reason for the price variation is that different bowls have different choices, and hence, have different final costs depending on the alterations.

Another reason is that there could be multiple Barbacoa Bowls ordered at once (in the same order), so item price would be larger.

However, I wanted to make sure that this is a legitimate claim (specifically the multiple Barbacoa Bowls part). Using

chipo[chipo['item_name'] == 'Barbacoa Bowl']['quantity'].unique()

I get output

array([1])

Which implies that all quantities are 1. So is my answer still legit? It doesn't seem supported by our data set but I can't think of any other possible reason for this, other than heterogeneity of stores (there are 2 stores in our sample, but there is no data on the stores' individually pricing itself).

Thanks!

jmbejara commented 5 years ago

Yeah, I think your answer is correct. You're right, it looks like the Barbacoa Bowl doesn't seem to have any cases of quantities varying from 1. However, it looks like there is this kind of variation with Chicken Bowls.

image

Also, just FYI, the query method is a nice, readable function that I like. You may have used it before. In case not, here's an example. These two things are equivalent:

chipo[chipo['item_name'] == 'Barbacoa Bowl']
# same as
chipo.query("item_name == 'Barbacoa Bowl'")

https://jakevdp.github.io/PythonDataScienceHandbook/03.12-performance-eval-and-query.html#DataFrame.query()-Method