Chipotle Orders: Uncovering Pricing Patterns and Insights

Load the Chipotle order CSV into a DataFrame, clean and convert price strings to numeric, rename the DataFrame to chipotle_orders, and identify the most expensive item ordered by filtering the maximum item price.

Gain insights into Chipotle’s ordering data by analyzing a CSV dataset containing over 4,000 individual records. Learn how to process and clean item prices, identify the most expensive order, and begin investigating revenue trends per item.

Key Insights

  • The dataset consists of 4,622 rows representing individual Chipotle orders, each with attributes like order ID, quantity, item name, choice description, and order-specific price.
  • To analyze item prices quantitatively, order prices—originally stored as strings with dollar signs—are converted to numerical float values using a lambda function with pandas’ apply method.
  • The most expensive recorded order item was 15 servings of chips and salsa, totaling $44.25, demonstrating how customizations and quantities affect order pricing.

Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.

We have a CSV of Chipotle data called chipotle.csv. Let's get into a data frame and check it out. I'm going to call it chipotle for now. I'm probably going to end up changing that, I feel like, when we sort of explore it and see what this variable should be called.

Like, what chipotle data is it? Let's find out. We'll run Pandas's readcsv function and the name of the file is chipotle.csv. It's in this directory, so you just need to write that file path. And then let's check out this chipotle.

Okay. Looking at it, we have order ids, quantities, item name, choice description, and order price. Now, this data can be a little confusing.

Fun thing, there's a lot of it. 4,622 rows. And it can take you a little while to stare at this and really backtrack and reverse engineer exactly what this data is doing.

But you don't need to do that, because I've done it for you. So, what we have here is many different orders. And for each of these orders, I think it might actually help if we look at maybe a sample of 30.

Python for Data Science Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

So, we can see that some of these items have quantities to them. And they all have an order price. Now, you would think that a chicken bowl is a good example.

We have two chicken bowls right next to each other here. But this one has a price of $8.75, and this one has an $11.25. So, order price is not a bad name. We can think about changing that.

It sort of implies that it's the price of the item. Oops, I'm creating a note for myself. So, what we want is to have an understanding of what this is, which is this is the price of that particular item in that particular order.

And that might include some substitutions or add-ons, whatever it is. You can customize your food order at the restaurant or Chipotle, and you should. And there's lots of different prices that can result from that.

And that's why we have this order price that is kind of like the price of the item, but it's the price of the item for that order. Okay. So, we're going to do some work to understand this.

We're going to try to find out what the most expensive item was. Yeah, let's do that. So, the most expensive item in the order, how can we find that out? Well, we can use a lambda to get all the prices, but without these dollar signs.

Okay. So, we could say, all right, let's make a column called maybe item price as number. Are these all underscores and lowercase? Yeah, let's keep to that then.

We'll say Chipotle, and now that I'm thinking about this variable name, yeah, I don't love it. I'm going to rename it before it drives me crazy. These things are not Chipotles.

These are Chipotle orders. I think that's reasonable. Chipotle orders.

Okay. Make sure that still works. Yep.

Rerun that cell if you rename a variable. All right. So, the most expensive, we can say Chipotle orders at item price as number equals and apply.

Chipotle orders at item price. No, sorry. It's not called item price.

It's order price dot apply. And when you do, this line is getting a little long, so I'm actually going to open up a little bit of vertical space. You can absolutely do that, and I encourage you to do it.

And we'll pass in a lambda that takes in a price, and remember, each of these prices is one of these dollar sign and, you know, it's all a string, 11.25. So, we needed to say, give me the float version of it, and what you, because you convert to a float is the version where we've taken the price and we've stripped out the dollar signs. Let's look at our Chipotle orders. There we go.

Item price is number, and they're always equivalent, but as a number, no dollar sign. Great. Now, to find the most expensive item there, we can say highest price is Chipotle orders at item price as a number.

Now that we've got it as a number, we can work with it numerically and say, okay, give me the max, and let's check out highest price. It's 44.25. What item was 44.25, you might ask? Let's find out. Let's say, I want to filter this by ones where the price was that highest price.

So, we'll say Chipotle orders item price as number, double equals that highest price. Give me only the rows in Chipotle orders where this was true, and there it is. Somebody ordered 15 chips and salsas, and it came out to a hefty 44.25. That's the single biggest item in an order.

Okay. Now, we're going to do a little bit of work to investigate this data a little bit more and start to think about revenue for each of these items.

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Python

Master Python with hands-on training. Python is a popular object-oriented programming language used for data science, machine learning, and web development. 

Yelp Facebook LinkedIn YouTube Twitter Instagram