Data Scientist · Step 7 of 8 · 10 min
Working with AI and LLMs as a data scientist
Use AI assistants for code safely and decide when an LLM is the right tool for the job.
AI as a coding partner
Code assistants built into notebooks and editors, and general chatbots, are now part of daily data work. They are good at boilerplate, at remembering the exact pandas or matplotlib syntax, at explaining an error, and at suggesting a first draft of an analysis.
Use them, but stay the author. Ask for small pieces you can understand, not a whole project. If you cannot explain a line, you are not ready to ship it.
Check generated code like a reviewer
Generated code can run without errors and still be wrong. Common traps: a merge that silently duplicates rows, filling missing values before the train/test split, a function or argument that does not exist in the library version you use, or a metric computed on training data.
Check row counts after each step, compare results with a quick manual calculation on a few rows, and read the official documentation for any function you have not used before. Treat confident code the way you would treat a confident stranger.
LLM or classic model?
Large language models are strong at messy text: summarising feedback, tagging support tickets by topic, pulling fields out of documents. For predicting a number or a category from a clean table, a classic model such as logistic regression or gradient boosting is usually cheaper, faster, more stable and easier to explain.
A sensible test: could a simple model on structured columns do this? Then start there. If the input is free text and labels are scarce, an LLM API may be the faster route. Either way, evaluate it on held-out examples like any other model.
Privacy comes first
Never paste personal or confidential data into a consumer chatbot: names, emails, phone numbers, medical or financial details, or your employer's internal data. Depending on the product and settings, what you type may be stored or reviewed, and it may break your company's rules or data protection law.
Use the tools your organisation has approved, which often come with data agreements. When asking for help, describe the columns or share a few made-up rows instead of real ones.
Try it
Get help without sharing real data
- 1.Pick an analysis you want to do and write down only the column names and types.
- 2.Use the prompt below with fake example rows you invent.
- 3.Run the code on your real data in your own notebook, and check row counts after every step.
I have a pandas DataFrame with these columns: [COLUMN NAMES AND TYPES]. Here are 3 made-up example rows: [FAKE ROWS]. Write pandas code to [GOAL]. Add a comment on each line, an assert that checks the row count after any merge, and tell me which library versions this assumes.