Overview

2 A chat with ChatGPT

This chapter introduces how to put ChatGPT to work for data analysis, beginning with a quick orientation to the web interface and a first dialogue to set expectations about capabilities and limitations. It explains essential controls such as example prompts, the input field, starting a new chat, choosing a model, and regenerating answers, and it highlights conversation memory and history. Throughout, it emphasizes prudent use: language models can sound convincing while being wrong, so users should verify outputs and remain mindful of issues like hallucinations.

The chapter then demonstrates direct analysis of native text data. Using a fictional product review, it shows classification into domain categories, sentiment detection, extraction of positive and negative aspects with tightly specified output formats, and summarization at different levels of brevity. It also illustrates drafting friendly replies to customers and refining them with follow-up instructions, reinforcing how precise prompts yield concise, consistent results suited for aggregation. Finally, it notes practical constraints such as context limits and the need to scale beyond single examples by automating the flow of many documents.

For tabular data, the chapter presents two complementary approaches. First, within the ChatGPT interface, users can upload a dataset (e.g., CSV) and have ChatGPT generate and execute Python code to compute answers, with the option to inspect the analysis; this is convenient but subject to file-size, performance, and privacy constraints. Second, it shows how to use ChatGPT indirectly as a translator from natural language questions to formal languages such as SQL for external tools (e.g., an RDBMS), including schema description, query generation for counts, top categories, and ratios, and the importance of validating code and tightening outputs to match exact requirements. The chapter closes by motivating further automation to streamline these workflows end to end.

Signup page for OpenAI account. Enter your email address (“Email field”) and click on the Continue button (“Continue”) or sign up using a Google account (“Google login”) or a Microsoft account (“Microsoft login”).
figure
ChatGPT Web interface: interact with ChatGPT by clicking on pre-defined example inputs or enter arbitrary text into the input field. Click on the “New chat” button to reset the conversation.
figure
After ChatGPT generates an answer, the “Regenerate” button appears below the generated response. Click on this button to receive an alternative answer to your last input.
figure
Click on the “Upload button” and choose the option “From computer” to upload files on disk.
figure
Answer generated by ChatGPT for a question about the input table. Click on the “Show analysis” button to see how ChatGPT calculated the answer.
figure
Google Colab notebook allowing you to query the BananaDB database via SQLite. Execute the upper cell (“Create database”) to create the database, replace the given SQL query (“SQL query”) with a query of your choice, and then execute the lower cell (“Execute query”) to see the query result. The arrow marks the “Run” button used to execute the upper cell.
figure
The ChatGPT Web interface uses specialized markup to represent code, including SQL queries. Click on the button marked by the arrow to copy the code (making it convenient to paste the code into suitable interfaces for execution).
figure

Summary

  • Language models can solve various tasks, given instructions in natural language.
  • While powerful, language models can produce incorrect output.
  • You can use ChatGPT via a Web interface in your Web browser.
  • ChatGPT enables users to interact with various GPT model versions.
  • To process text with ChatGPT, enter the text and a task description.
  • ChatGPT can classify text, given classification categories.
  • ChatGPT can extract information from text, given corresponding questions.
  • ChatGPT can produce text summaries according to user specifications.
  • ChatGPT is not suitable for processing large data sets directly.
  • However, ChatGPT can generate code that processes large data using other tools.
  • To produce code, enter a description of the data, the task, and the output format.

FAQ

How do I access ChatGPT and create an OpenAI account?Open a browser and go to https://chat.openai.com/. Click Signup and choose one of: sign up with Google, sign up with Microsoft, or sign up with any email address and follow the on-screen steps. Then log in to start.
Do I need a paid subscription for the examples in this chapter?No. A free account is sufficient. Paid plans can provide access to more models and faster responses, and your screens may look slightly different.
How do I start and manage conversations in the Web interface?Type into the input field to chat. ChatGPT remembers prior turns in the same conversation. Use New chat to reset context. Past chats are saved and accessible via History.
What if I don’t like an answer?You can ask ChatGPT to revise or correct it without repeating the original request. Or click Regenerate to get an alternative answer; outputs can differ because generation includes some randomness.
What are hallucinations and how should I handle them?Hallucinations are confidently stated but invented details. Always verify outputs with other sources. There’s active research, but no guaranteed way to avoid them—don’t trust responses blindly.
What text-processing tasks can ChatGPT handle directly?- Classify reviews by product category or sentiment (e.g., satisfied/dissatisfied) - Extract key positive/negative aspects in a specified format (e.g., numbered list with short phrases) - Summarize reviews (e.g., one sentence or three sentences) - Draft friendly replies to customer reviews It follows format instructions when you state them clearly.
How do I keep outputs concise and consistent for aggregation?Be explicit about the format (e.g., “Answer with only one of: mobile phones, personal computers, game consoles” or “numbered list with max three words each”). Ask to “answer concisely” and restrict labels to a fixed set.
Can I analyze tables in the Web interface, and how?Yes. Upload your CSV (Upload → From computer), then ask questions about the data. ChatGPT generates and runs Python code behind the scenes; click Show analysis to inspect it. Note constraints: file size limits (e.g., 512 MB at writing) and possible multi‑second runtimes.
When should I prefer external tools over the Web interface?Use external tools when data is large (upload limits), performance matters (big datasets), or privacy prevents uploading data. ChatGPT can translate plain‑English questions into code (e.g., SQL) for tools you control.
How do I use ChatGPT to generate SQL for SQLite and run it?Tell ChatGPT your system (SQLite 3), table name (e.g., Reviews), and columns with meanings. Ask for queries (e.g., top category, positive‑review ratios). Copy the SQL from the code block into your execution environment (e.g., the BananaDB Colab cell); wrap multi‑line SQL in triple quotes. Review the explanation and verify results.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Data Analysis with LLMs ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Data Analysis with LLMs ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Data Analysis with LLMs ebook for free