Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

How to automate work tasks with ChatGPT and Python

Here are five ways you can use ChatGPT and Python to automate time-consuming tasks that slow down your day, with practical examples you can follow.

May 21, 2024 • 6 Minute Read

Please set an alt value for this image...
  • Data
  • Business
  • AI & Machine Learning
  • Guides

By now, you’ve surely used ChatGPT to craft emails, conduct research, write jokes, or generate code. And yes, that’s all really amazing, but the true power of this AI tool is its ability to automate tasks that eat into our productivity every day.

Whether you’re an experienced data analyst, a newbie developer, or someone without a heavy tech background, this post is for you. We’ll look at five practical ways you can use ChatGPT and Python to automate those tedious work tasks.

Table of contents

1. Exploring and visualizing your data with the Data Analyst GPT

Data is critical for so many jobs today. Being able to understand and visualize the data you’re working with is key to success on many projects. But even if you’re super comfortable writing Python code and using libraries like seaborn, matplotlib, and pandas, let’s face it: It’s time-consuming to do.

With the Data Analyst GPT, your life just got a whole lot easier. This custom GPT not only does data exploration and visualization for you but also writes the Python code you need to do similar work in the future. It also makes it easy to upload data files for analysis.

If you haven’t used it before, go to ChatGPT, then Explore GPTs.

Scroll down to By ChatGPT, then click on Data Analyst.

In the pop-up window, click Start Chat.

Drag and drop your data file and tell the Data Analyst what you want to do. In my case, I’m using a dataset for customer churn (i.e., when a customer leaves a company) at a mobile phone provider. It contains a column for “Churn?” that indicates the customer left. I want to understand the relationship between that column and the others so I can predict future churn (a machine learning problem).

After you submit the prompt, the Data Analyst will get busy, giving you suggestions on the best way to analyze and visualize your data. Here’s an example of the response for my particular dataset.

In most cases, you’ll also see a link to View Analysis at the end of its answer.

This will open up a window of Python code the Data Analyst used to do the analysis in its answer. You can copy this code into a reusable script or use it in whatever way makes sense for your scenario.

Continue your conversation with the GPT. It should provide insight into different kinds of analyses and visualizations you can do. In my case, I created a correlation matrix heatmap and box plots, shown below (and, of course, it generated the Python code for those that I can reuse in the future).

2. Using Python to create charts from Excel data

For this example, we’ll once again use the Data Analyst GPT. I have an Excel workbook of product sales data. I have an idea of the type of visualization to create, so I’ll ask for a bar chart. If you have a specific color scheme in mind, you can specify that, too.

I have a bar chart in green like I asked for, and I can also view and copy the Python code used to create it.

Sometimes you don’t really know the best type of visualization for the data. Is it a bar chart, a pie chart, a scatter plot, something else? The Data Analyst GPT can help with that, too. After it’s loaded the data and “understands” it, the GPT can help you pick the best kinds of visualizations. Just ask.

And voila! Our answer and a pie chart.

3. Extracting data from a PDF and converting it to a CSV

So far, we’ve seen how to work with CSVs and Excel files—two of the more common file types for data. But you might also get data in a PDF format, which can be a real pain to copy-paste and get into the format you need. Once again, the Data Analyst GPT comes to the rescue.

For this example, I’m using a 68-page report from McKinsey & Company called “The economic potential of generative AI.” On page 25 of the report is this graphic with lots of good data.

The data isn’t really in a format that’s easy to use, though; I want it in a CSV.

So, I’ll just ask. Notice here I’m uploading the entire report (because who has time to separate PDF pages?) and pointing the Data Analyst to Exhibit 4.

After analyzing the data, Data Analyst converts it to a CSV format and provides a link to download it.

Opening the CSV in Notepad, it looks like the information was correctly extracted and formatted. Yay!

4. Extracting and translating blog titles using ChatGPT and Python

Another task that can be time-consuming and tedious is creating outlines from existing articles and blog posts. And maybe you also need to translate those into other languages for an international audience. Once again, we’re going to get some help from ChatGPT.

Here, we’ll use “regular” ChatGPT, not the Data Analyst GPT. For the article, I’ll pick one from the Pluralsight blog, Getting started with LangChain: How to run your first application. This should work for any blog post with a URL and one that uses HTML heading tags (I’ll be grabbing <h2> and <h3> tags). I’ll ask to translate the blog headings into French.

ChatGPT wrote the code to do this (below) using the following libraries: requests, BeautifulSoup (for web scraping), and googletrans (for translation). I copy-pasted the code into a Jupyter Notebook and ran it. And, as you can see, we have the first several blog post headings at the end in English and French

5. Using ChatGPT and Python for web scraping

Our final example is how to do web scraping using a Python script. Not all sites allow scraping, but this one, Books to Scrape, is all about it. This site contains book information like title, rating, price, whether it’s in stock, etc. We’ll ask ChatGPT to help us create a script to grab this information.

As expected, ChatGPT generates Python code for us, once again using BeautifulSoup for web scraping. I copy-pasted the code into a Jupyter notebook, ran it, and like magic, I got back the list I asked for. Niiice!

Wrapping up

So there you have it—five specific ways you can use ChatGPT and Python to automate some of those time-consuming tasks that slow down your day. Whether it’s exploring data and visualizing it, or extracting and scraping things from the web, your AI assistant makes it a lot easier.

If you want to learn more about using ChatGPT to code and create applications, check out these resources:

Amber Israelsen

Amber I.

Amber has been a software developer and technical trainer since the early 2000s. In recent years, she has focused on teaching AI, machine learning, AWS and Power Apps, teaching students around the world. She also works to bridge the gap between developers, designers and businesspeople with her expertise in visual communication, user experience and business/professional skills. She holds certifications in machine learning, AWS, a variety of Microsoft technologies, and is a former Microsoft Certified Trainer.

More about this author