Skip to main content
Colin Jaffe/3 min read

Building a Dash App: Data Processing and Visualization

Dash App Build Checklist

0/5
Master Python at Noble Desktop

Noble Desktop's Python Programming Immersive covers AI APIs, data analysis, and modern Python development.

This lesson is a preview from our Data Science & AI Certificate Online (includes software) and Python Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

So you should be ready now for us to get into the Notebook2 directory and run our app.

So you should be ready now for us to get into the Notebook2 directory and run our app. Let's give it a try. We'll need to cd into Notebook2 from within our main directory into our Notebook2 directory.

And now it should say Notebook2 or in Windows, a long path ending with Notebook2. And now we will say, okay, let's run Python app.py and it should give us a URL. And what you want to do is copy that, switch to a browser, and there we go.

Hello Dash. That means that that worked just fine. Everything's running smoothly.

Let's switch back to vs. Code and add to this, change it, bring our work in that we were doing before. We need to, we've imported a lot of the things we need. Dash, HTML, Plotly Express, Pandas, etc.

Now before, I like to add some sort of section information on this. This is server code. Above here, I'm going to put data code, maybe.

And here where we're going to read in our ordered items. Read CSV, chipotle.csv. And we could start out just being like, okay, did this work? Let's run ordered, let's print out ordered items. And if you save it, switch back to your terminal.

Great. It's printing out a view of our data frame. Fantastic.

Seems to have worked. You should ideally get rid of that print. We don't need it.


And now let's make an item prices number by applying a lambda to our item price. We can see here it's got order price. We want to take that and make that item price, maybe item prices number.

Let's try that. We'll say, ordered items item price as number equals ordered items order price dot apply. And I'm going to make an extra line here.

And we'll say, let's apply the lambda that takes in a price and returns a float. Where we pass in price stripped of its dollar sign. And we can check now.

Okay, what's ordered items? Save it. Switch back. Oh, yep.

Now it's got an item price as number column. And it looks more numbery. So I think we did it.

Okay. Now I want to group them. Let's get revenues.

We'll take our ordered items and group them by item name. And look at the item price as number column. And aggregate it by the sum of item price as number.


Let's print out revenues. There they are. Look just like they did before in our notebook.

All right. Our code's going great so far. Let's make it the, we'll just skip right to making it the top five this time.

Revenues and largest five. And let's print our top five. See if that worked.

There it is. Grouped and sorted by the five largest. All right.

That's it for our data code. Let's start doing some graphs. We'll say, yeah, let's make some figures.

We're going to make a few figures. And then we'll try to see if we can get them onto our dashboard. Coming up.