We've all been there. The dreaded 4:00 PM on a Friday afternoon email from the boss, asking for "updated numbers". There goes your weekend plans. Time to text your friends and family:
For me, this happened a few times. And then I found a way to save myself so much time. The answer: Interactive dashboards that can be updated in seconds with Python.By the way, if you haven't snagged your copy of The Data Analytics Portfolio Playbook, now's the time! Get up and running in two weeks or less. Data visualizations are awesome for your portfolio. The playbook includes everything you need to create an awesome portfolio -- including how to host for free. Here's a specific example of what's possible when you follow the proven playbook. I got started simply. And that's what I recommend others do as well.
And now? I build interactive dashboards that not only look sleek but tell the story behind the data. With a few clicks, I can see patterns, make predictions, and deliver insights that used to take days to uncover. And it's all thanks to Python. And you can do it too. In this guide, I'll walk you through step-by-step how to turn data into a dashboard with Python. If you follow these steps for your next project, just imagine how you'll feel:
There's no going back once you have these skills. Alright, let's visualize, letting Python do the heavy lifting. Step 1: Import Necessary LibrariesFirst things first, let's import the libraries we need. Paste this code into a new Google Collab notebook cell and run it. You can use my notebook to help you get started.
Step 2: Load and Preprocess the DataNow, let's load our insurance data. Use Pandas to read the CSV file and then make sure we convert dates and convert columns with $ symbols to numeric for easy analysis.
Step 3: Create a Basic Plotly GraphBefore diving into Dash, let's create a basic Plotly graph. This helps us understand our data visually. Create four different graphs:
Step 4: Set Up Your Dash AppNow that we have a good sense of the data and some basic visuals, let's put them together. Dash is an open-source Python framework for creating awesome interactive web applications effortlessly. It's perfect for turning data analysis into visual insights with minimal coding. Here's how to do it:
This might look complicated, but a lot of it is styling. I think adding in better formatting really makes a difference. But all the code is doing is creating the app object, defining the layout, and then adding the charts to the layout. No need to overthink this step! Step 5: Add Callbacks for InteractivityDash uses callbacks for interactivity. If you aren't familiar with callbacks, imagine you're playing a video game, and when you press a button, something cool happens on the screen—that's like a callback in Dash! In Dash, a callback is a piece of code that waits for something to happen (like pressing a button or picking something from a list), and when it does, the callback makes the app do something in response, like show you a new chart or update what you see on the page. Let's add one for each graph to update our dashboard based on the selected car make:
Step 6: Run Your AppFinally, let’s run our app! Add this at the end of your notebook:
Here's what you'll see in Google Colab:
Great job! The idea for this newsletter came directly from a reader – just like you! Take 3 minutes to let me know what you want help with next. Until next time, keep exploring and happy visualizing! Brian Whenever you're ready, here's how I can help you:
|
You are receiving this because you signed up for Starting with Data, purchased one of my data analytics products, or enrolled in one of my data analytics courses. Unsubscribe at any time using the link below. 600 1st Ave, Ste 330 PMB 92768, Seattle, WA 98104-2246 |
Learn to build analytics projects with SQL, Tableau, Excel, and Python. For data analysts looking to level up their career and complete beginners looking to get started. No fluff. No theory. Just step-by-step tutorials anyone can follow.
Quick note: Before you read this week's newsletter, can you fill out this 5-minute subscriber survey so I know what you want to know more about? I've got a mix of SQL and AI & Agentic Analytics right now. Thanks in advance! Hello Reader, A manager sends you a database login and says, "Can you pull a few customer insights before Friday." You connect to the database and you pause: Because, as a business analyst, there are two ways to respond: Panic and start feverishly writing the SQL, joining...
Hello Reader, This week's newsletter is different. No SQL code. No database queries. I lead a team of 30 data professionals, and we use tools like Claude and Copilot to get oriented, draft, review, and explain routine analysis. The useful part is moving faster without handing over the judgment your team relies on. We call this "human in the loop". Agentic Analytics means using AI as part of your analytical process: give it context, check its work, and keep responsibility for the decision. I...
Hello Reader, Real quick: if you haven't completed this subscriber survey -- now's your chance. Most people are looking to learn more about Agentic Analytics and AI topics. I want to build something that would be useful to you, based on the work I've been doing for the past year or so. Interested? Take 5 minutes to let me know what's on your mind. Take the 5-Minute Survey Now 👉 Imagine it's your first week at a new job. Someone from IT sends over database credentials and a two-line email:...