Retext
GitHub CopilotCopilotFor Data Scientists

GitHub Copilot Prompts for Data Scientists

Data scientists need help writing and debugging pandas or SQL, choosing and checking statistical methods, and explaining results to people who will make decisions from them. These GitHub Copilot prompts start from that: fill in your situation once and reuse it. The worked example below is a debugging task, one of the most common for data scientists.

Installs as a snippet — type ;data-copilot to paste this prompt anywhere on your Mac.
Prompt Template
I'm a data scientist and need help with [task, e.g. data analysis and visualization].

What I have:
- [the material involved: code, draft, notes or data]

What a good result looks like:
- [the outcome and its format]

Ask me one clarifying question if something important is missing, then give the result.

About my work
- Data shape and types: [e.g. 2M rows, columns: user_id, signup_date, plan, churned (bool)]
- Tools and environment: [e.g. Python 3.11, pandas 2, scikit-learn, Jupyter]
- Question the analysis must answer: [e.g. which plan features predict churn in the first 90 days]

Context
- Files involved: [list the files, or reference them in the chat]
- How I build and test: [e.g. npm test]

How to use this prompt

  1. 1

    Open GitHub Copilot

    Open Copilot Chat in your editor and paste the prompt.

  2. 2

    Give it context

    Select the relevant code first, or reference files in the chat, so Copilot answers about your code rather than in general.

  3. 3

    Review and iterate

    Ask follow-ups in the same thread, and copy or insert the suggestion only after you have read it.

  4. 4

    Save what you repeat

    Keep repository-wide guidance in a .github/copilot-instructions.md file so it applies to every chat in that repo.

Working in GitHub Copilot

  • •Inline suggestions only see the file you are in. Use Copilot Chat for anything that spans several files.
  • •Copilot Chat has built-in slash commands such as /explain, /fix and /tests. The prompt here gives more control when you need a specific format.
  • •Short, concrete requests work best: name the function, the input and the expected result.

Example task: Debugging

What you give it

Symptom: add_tag returns tags from earlier calls. Calling add_tag("a") then add_tag("b") gives ["a", "b"] on the second call instead of ["b"].
Environment: Python 3.11, local script.

def add_tag(tag, tags=[]):
    tags.append(tag)
    return tags

What changed: nothing, it has always done this.

What a good answer looks like (shortened)

1. Mutable default argument (very likely). The list [] is created once, when the function is defined, and every call without a tags argument reuses that same list.
   Check: print(id(tags)) inside the function. If the id is the same on every call, this is the cause.

2. A caller is passing the same list in each time (less likely, since the calls you showed pass only one argument).
   Check: search for calls to add_tag that pass a second argument.

Run check 1 first. If confirmed, the fix is:
def add_tag(tag, tags=None):
    if tags is None:
        tags = []
    tags.append(tag)
    return tags

Tips for better results

  • •Describe the data with df.dtypes and a few sample rows (with sensitive values removed) instead of words. The AI writes far more accurate code when it sees real column names and types.
  • •Select the relevant code first, or reference files in the chat, so Copilot answers about your code rather than in general.
  • •Check this before you use the output: verify that suggested methods fit your data's assumptions, and watch for data leakage between training and test sets in any modeling code.

Check before you use it: Verify that suggested methods fit your data's assumptions, and watch for data leakage between training and test sets in any modeling code.

Get the free prompt pack

Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.

Variations

Task

Debugging: Replace the first line with: Help me debug a problem. I want to find the cause, not just patch the symptom.

Intermittent bug

Add this line to Symptom: It only happens [e.g. 1 in 20 requests, under load, after midnight UTC]. Focus on timing, concurrency and caching causes.

Second task

Change the task line to: [Building ML models].

Save it as a Retext snippet

Retext is a free text expander for Mac. Save this prompt once, then type ;data-copilot in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.

  1. Click Add to Retext. The prompt installs as a snippet with the trigger ;data-copilot.
  2. Change the trigger in Retext if you prefer a different one.
  3. Type the trigger wherever you want the prompt, then fill in the brackets.

Frequently asked questions

Can AI choose the right statistical test for my data?

It can suggest options and explain their assumptions, which is a useful check. You still need to confirm the assumptions hold for your data, like independence, sample size and distribution.

Does this prompt work with inline suggestions or only chat?

Use it in Copilot Chat. Inline suggestions complete code as you type and don't take long instructions like this.

How do I give Copilot project conventions once?

Add them to .github/copilot-instructions.md in the repository. Copilot Chat includes that file with your requests in that repo.

How do I reuse this prompt without copying it every time?

Click Add to Retext to save it as a snippet. Then type ;data-copilot in any Mac app, including your AI tool, and the full prompt is pasted in.

Related Templates

Get the free prompt pack

Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.