Streamlining Interactive Maps with ChatGPT, Python and Plotly Dash

Prompt engineering interactive Python data visualizations

John Loewen, PhD
Data And Beyond

--

Final working maps using prompt engineering with Python dash and folium libraries

In the recent past, creating data visualizations, particularly in Python, was a finicky affair.

Not anymore.

In this article, two datasets, each organized by country and year, are compared to draw meaningful insights. A solution to display the data on two maps side-by-side, to allow comparison by year, is proposed. To solve this problem, prompt engineering with ChatGPT is used to efficiently generate interactive Python data visualizations in just 4 steps:

  1. Find, clean, and convert the datasets
  2. Generate a folium map
  3. Generate dash App with dropdown menu to display folium map (by time period)
  4. Generate a second map to display and hook it in to the Dropdown, update both maps with one selection

A modular approach like this is recommended as it gives us a return point to go back to if there are any problems.

So let’s get started…

STEP 1. Find, clean, convert.

What dataset should we use today? I don’t know about you, but I think coffee is awesome. It is warm, soothing, tasty…

--

--

John Loewen, PhD
Data And Beyond

20x Boosted writer || 25 years Comp Sci prof || Writes about Data Science (Python/AI/dataviz) || More on my Substack: johnloewen.substack.com