profile

Starting With Data

🟒 Creating an Interactive Help Desk Ticket Analysis Dashboard from Scratch with Python Using Plotly (Code Included)

Published 6 months agoΒ β€’Β 5 min read

Starting with Data

Actionable data analytics tips, tricks, and tutorials to increase your earning potential. Delivered right to your inbox every Saturday.

Creating an Interactive Help Desk Ticket Analysis Dashboard from Scratch with Python Using Plotly (Code Included)

Data visualization is a huge topic. And if you're not using it in your work, you're missing out.


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.


This is because it's MUCH better to show your work than not to.

Quick results without cumbersome business intelligence tools.

Don't get me wrong: I love Tableau.

But there's a problem: Most people think you have to have a tool like Tableau to create interactive dashboards.

And that's not true.

You can create a "quick and dirty" interactive dashboard with Python and Plotly.

  • Quickly show your analysis interactively.
  • Get quick feedback on what works (and what doesn't).
  • Automate your visualizations -- since everything's in Python.

Python + Plotly makes your work shine.

Sure, you can use Excel to create bar charts. And sometimes Excel is the right tool for the job.

But there are times when you don't want to:

  • Stop using Python
  • Export your data to CSV or Excel
  • Open Excel
  • Create a bar chart (3 hours of Excel hell)
  • Send it off for review
  • Stay in Excel to make tweaks (2 more hours of hell)
  • Get back into Python
  • Make more tweaks. More exports. More hell.
  • Repeat.

The step-by-step process to work faster and easier.

In this guide, you will learn:

  • Importing and exploring data
  • Creating charts and graphs in Python
  • Putting your visualizations into an interactive dashboard
  • Exporting that for quick review as needed.

Before we get started, make sure you have Google Colab set up and ready to go. You can follow along using this Python Notebook as a template to guide you.

Alright, let's visualize!

Step 1: Gather and Inspect Your Data

First things first, let's import the libraries we'll use. Paste this code into a new Google Collab notebook cell and run it.

import pandas as pd
import plotly.graph_objs as go
from plotly.subplots import make_subplots

# Load the CSV file
file_path = 'https://query.data.world/s/v4a3g3gvhjtki5kzpx55ggllobsoxo?dws=00000'
data = pd.read_csv(file_path)

# Take a peek into the data
data.head()

Step 2: Clean and Prepare

Now that the data is loaded and is looking good, let's clean it up. In this step, we convert the date column to a datetime type and clean up any missing or invalid data.

# Convert 'created_date' to datetime
data['created_date'] = pd.to_datetime(data['created_date'])

# Check for missing values
missing_values = data.isnull().sum()

# Remove missing values as necessary
# For the sake of this example, let's fill missing categorical data with 'Unknown'
categorical_columns = data.select_dtypes(include=['object']).columns
data[categorical_columns] = data[categorical_columns].fillna('Unknown')

Step 3: Trend Analysis

Before we create the interactive dashboard, take a look at the data in a simple chart just to make sure things are looking good and our date columns are all set for visualization.

This step is technically optional but good to prevent you from having to troubleshoot later down the road.

import matplotlib.pyplot as plt

# Set the style for our plots
plt.style.use('seaborn-darkgrid')

# Group by the created_date and count the tickets
trend_data = data.groupby(data['created_date'].dt.to_period('M')).size()

# Plot the trend
trend_data.plot(kind='line', figsize=(12, 6), color='navy', linewidth=2)

# Make it pretty
plt.title('Monthly Help Desk Ticket Trends')
plt.xlabel('Month')
plt.ylabel('Number of Tickets')
plt.show()

Step 4: Dig Deeper into Categories

Now that we have a trend line, let's dig a bit deeper to get counts for different categories.

This is a quick step, but it shows the flexibility of Python. You can update this to count anything in the data set and then visualize it in the next steps.

# Create Issue Category and Ticket Type variables
issue_category_counts = data['issue_category'].value_counts()
ticket_type_counts = data['ticket_type'].value_counts()

Step 5: Combine the charts into an interactive dashboard

Next, let's take the visualizations and put them into a dashboard.

This is a big step and there's a lot going on. But let's break it down, step by step:

  1. Create the dashboard object with 1 row and 3 columns that will hold our subplots.
  2. Create the 3 subplots (Monthly Ticket Trends, Issue Category Counts, and Ticket Type Counts) that will get added to our dashboard.
  3. Set the chart type for each of the 3 subplots.
  4. Add the subplots to the dashboard
  5. Adjust some formatting

And here's the code:

# Set up the subplots
fig = make_subplots(
    rows=1, cols=3,
    subplot_titles=('Monthly Ticket Trends', 'Issue Category Counts', 'Ticket Type Counts'),
    specs=[[{"type": "scatter"}, {"type": "bar"}, {"type": "bar"}]]
)

# Add the trend line plot
# Referencing the variable created in Step 3
fig.add_trace(
    go.Scatter(x=trend_data.index.astype('str'), y=trend_data.values, mode='lines+markers'),
    row=1, col=1
)

# Add the issue category bar chart
# Referencing the variable created in Step 4
fig.add_trace(
    go.Bar(x=issue_category_counts.index, y=issue_category_counts.values),
    row=1, col=2
)

# Add the ticket type bar chart
# Referencing the variable created in Step 4
fig.add_trace(
    go.Bar(x=ticket_type_counts.index, y=ticket_type_counts.values),
    row=1, col=3
)

# Remove the legend for readability
fig.update_layout(title_text="Help Desk Ticket Analysis Dashboard", showlegend=False)

Step 6: Showcase Your Work

Finally, let's create the dashboard file for easy viewing:

# Create and save your dashboard as an HTML file
# In Google Colab, you can view this by clicking the file folder icon (πŸ“)
# on the left hand side of the screen.
dashboard_path = 'your_dashboard.html'  # Choose your path
fig.write_html(dashboard_path)

Here's where to find it in Google Colab:

And here's the final result -- well done! (Click here if you can't see the animated GIF below)

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:

  1. Get more data analytics tips in my previous newsletter articles​
  2. Build your data analytics portfolio in 2 weeks with The Data Analytics Portfolio Playbook​

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.

113 Cherry St #92768, Seattle, WA 98104
​Unsubscribe οΎ· Preferences​

Starting With Data

Weekly data analytics tutorials and guides. 5 minutes to read.

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.

Read more from Starting With Data

Business leaders are dumb. That's what a lot of business analysts think because they create something "awesome" with a dataset and then it gets ignored. Unfortunately, these types of business analysts don't realize that leaders aren't dumb. They are just busy. They are responsible for making decisions and making them quickly. And leaders need answers (based on data) more than anything. Think about it: if they need answers and you have the skills to provide those answers... You become their...

5 months agoΒ β€’Β 5 min read

Starting with Data Actionable data analytics tips, tricks, and tutorials to increase your earning potential. Delivered right to your inbox every Saturday. Python Data Blending Made Easy: 3 Simple Steps to Combine Data Sets in Python (Even if You’re Not Sure Where to Start) Hey Reader, Have you ever been given a few different spreadsheets and had to combine them into one? Use clunky VLOOKUPs in Excel Copy and paste (hoping you don't break something) Give up and ask a more technical coworker...

5 months agoΒ β€’Β 3 min read

Starting with Data Actionable data analytics tips, tricks, and tutorials to increase your earning potential. Delivered right to your inbox every Saturday. Stop Guessing, Start Visualizing: Turn Retail Data into Decision-Making Tools with Interactive Python Dashboards (Tutorial + Code) Hey Reader, You won't get noticed unless you are solving real-world business problems. find a problem create a solution share your work land your dream job Pretty simple. The hard part is knowing where to start....

5 months agoΒ β€’Β 5 min read
Share this post