
How I Helped Optimize Donut Sales with Amazon Q
Amazon Q for Data Analysis
Published Mar 31, 2025
My co-worker's homemade donuts are a huge hit at home, especially when fresh from the oven. We would love to start selling them at the office we tried selling them twice and noticed as much as people enjoy them throughout the two days, sales peak when they're freshly baked.
To get the most sales and use the least effort she needed insights & validation on when to bring the donuts & not remain with any unsold ones. Being terrible at sales but a great customer I decided to use my little data analysis skills to see what we can do. To optimize her sales and production schedule, I analyzed the co-working space's check-in logs, examining members' clock-in patterns to determine the best times and days for selling donuts.
So first thing I did was get clock-in data from the IT department and make sure it was anonymized before doing some analysis.
I took data for the last 3 months: September October and November.
The data we have comprises of Date And Time Personnel ID, First Name, Device Name, Event Point, Verify Type, and Event Description.
From a glimpse, the data is about 8557 logs of every time someone checked in.
The first thing was to anonymize the data to maintain the privacy of the personnel in the office.
So I asked Amazon Q to help me do this
I promoted Amazon Q: I need code to anonymize data
The columns to anonymize are: Personnel ID, First name
Here is what Amazon Q came up with :

Amazon Q suggested hashlib library to scramble the plain text into unreadable text.
Here is the output and a few modifications to suit my context.
In the first part of the code we utilize salt :
Salting is a security measure that prevents hackers from quickly cracking passwords and data. Before hashing the data, Salt adds a random string of characters to it using
Salting is a security measure that prevents hackers from quickly cracking passwords and data. Before hashing the data, Salt adds a random string of characters to it using
os.urandom() .
We then have a function that converts the values to a string and combines it with the randomized output by salt. We then have a function that identifies the columns.
So now I have the anonymized data we can use to make an analysis and find the best time to sell some freshly baked donuts!
So now I have the anonymized data we can use to make an analysis and find the best time to sell some freshly baked donuts!
let's go!
Here is the output:

But now we want to the peak morning hour for activity
- Which weekday has the most morning activity? (Because she can only bake them in the morning)
- The distribution of activity across morning hours Detailed patterns for your busiest morning day so that she can bring them in at that point when they are still fresh.
So I prompted Amazon Q to with the above prompt.
Here is the output it gave :
- Here is the output :

So Tuesday is definitely the best day for us to for us to get the most sales.