GitHub Copilot in Jupyter Notebooks: Setup, Cell Context, and Verification
GitHub Copilot works in Jupyter notebooks through VS Code and the Jupyter extension. Here is how to set it up, write cells that get better suggestions, and check generated analysis code before you run it.
Updated 5 min read
GitHub Copilot works in Jupyter notebooks when you open them inside VS Code with both the Jupyter extension and the GitHub Copilot extension active. Copilot then offers inline completions in code cells the same way it does in a plain Python file. Tools like fenbs let you keep research questions, experiment decisions, and where you left off outside any individual session, so restarting a kernel or handing the project to a colleague does not lose the thread of the work.
This guide covers the setup, how cell structure affects the quality of suggestions, and how to check analysis code before running it on real data.
Does GitHub Copilot work in Jupyter notebooks?
Yes, with a few requirements. You need VS Code, the GitHub Copilot extension, and the Jupyter extension installed. Once all three are active and you are signed in with a GitHub account that has Copilot access, completions appear in code cells. Copilot also works in notebooks inside GitHub Codespaces, which runs VS Code in a browser. Check GitHub's Copilot documentation (opens in a new tab) for the current list of supported environments.
JupyterLab running on its own does not support Copilot directly. If your team uses a hosted JupyterHub or a cloud notebook service, check whether it offers a VS Code interface. The supported editor list on GitHub's docs is the authoritative source for what works today.
How to set up Copilot for Jupyter in VS Code
- Open VS Code and sign in with the GitHub account that has Copilot access.
- Open the Extensions panel and install the GitHub Copilot extension.
- Install the Jupyter extension from the same panel.
- Open or create a .ipynb file. Copilot activates automatically in code cells.
- Start typing in a code cell and look for the gray suggestion text. If nothing appears, check the Copilot status icon in the status bar at the bottom of VS Code.
For plan eligibility and licensing, see GitHub Copilot business plans and GitHub Copilot license. If suggestions appear but seem weak, the section below on cell context explains why.
How cell context shapes suggestions
Copilot reads the code visible in nearby cells when it forms a completion. In a short notebook this works well. In a long notebook, earlier cells can fall outside the context window, so a reference to a dataframe created far above may produce a less accurate suggestion.
Two habits help. First, keep your imports and data-loading cells near the top of the notebook rather than scattered across it. Second, write a brief comment above the cell you want Copilot to complete. A comment such as # calculate the 30-day rolling average for each column gives Copilot the target and usually produces a more useful first draft.
Descriptive variable names also matter. A name like monthly_sales_df gives Copilot more signal than df2. This is the same principle that makes GitHub Copilot memory work better: the more current context the tool can read, the more relevant its output.
Verifying analysis code before you run it
Copilot suggestions in data analysis notebooks need more scrutiny than suggestions in application code. An incorrect column name fails immediately with an error. An incorrect aggregation method or wrong handling of null values may return a number that looks plausible but is wrong.
Before running generated analysis code on your full dataset, check the column names it references, the statistical method it applies, and how it handles missing values. Running the code on a small sample first catches obvious errors without touching the real data.
When you find a mistake worth remembering, note it somewhere accessible. A correction that lives only inside one session disappears when the session ends, and the same error is easy to repeat in a later notebook.
Keeping research context across sessions
Copilot helps you write cells. It does not track which experiment you ran last week, what hypothesis you were testing, or what conclusion you reached. That context needs to live somewhere outside the notebook itself.
For work that spans multiple sessions or involves more than one person, an outside record becomes important. A colleague picking up the notebook needs to know the current question, the experiment already run, and what the next check is. Without that record, they re-read every output and may repeat work already done.
Keep your research context available for every session
Add the current research question, experiment decisions, and where you left off as context notes and tasks in fenbs. When you open a fresh session, your connected AI assistant reads the project context before helping. Record lessons from failed experiments so the next session builds on what you already know.
Create a free accountFree for one person · No credit card · Works with Claude, ChatGPT, Cursor and more
How to do this with fenbs
- Create a free account and add a project for the research or analysis work.
- Write the current research question and any constraints on the analysis as context notes in the project.
- Add the current experiment as a task with its plan and status.
- Connect your AI assistant over MCP from Integrations. Before each session, ask it to read the project context so it starts from the current question rather than a blank slate.
- After each session, record what was tried, what the result was, and what the next step is. Save unexpected findings as lessons so the same mistake does not happen twice.
fenbs does not replace the notebook. The notebook holds the code and outputs. fenbs holds the questions behind the code and the decisions about what to try next, so both you and a connected assistant can use either one without re-reading the other. See GitHub Copilot in RStudio for a comparable setup in a statistical analysis environment.