Using Cursor with Jupyter Notebooks for Data Science

Cursor 1.0+ added native support for Jupyter Notebooks, making it an excellent environment for data science workflows. This guide covers how to set up and use Cursor with .ipynb files, from basic editing to AI-assisted data analysis.
Prerequisites
- Cursor version 1.0 or newer
- Python 3.8+ installed
- Jupyter package installed (
pip install jupyter) - .ipynb file or project with notebooks
Opening Jupyter Notebooks in Cursor
Method 1: Direct Open
- Open Cursor
- Go to File > Open Folder and select your project
- Click on any
.ipynbfile in the Explorer - Cursor will open the notebook in the built-in editor
Method 2: From Terminal
# Navigate to your project
cd ~/data-science-project
# Open in Cursor
cursor .
Method 3: Create New Notebook
- Right-click in the Explorer sidebar
- Select New File
- Name it
analysis.ipynb - Cursor will create a blank notebook
Notebook Interface in Cursor
Cell Types
Cursor supports three cell types:
| Cell Type | Purpose | Shortcut |
|---|---|---|
| Code | Execute Python code | Y |
| Markdown | Write documentation | M |
| Raw | Unformatted text | R |
Basic Operations
| Action | Shortcut |
|---|---|
| Run cell | Shift + Enter |
| Run cell and insert below | Alt + Enter |
| Add cell above | A |
| Add cell below | B |
| Delete cell | D, D |
| Toggle line numbers | L |
Cell Toolbar
Each cell has a toolbar with:
- Run button (▶️) - Execute the cell
- Cell type selector - Switch between Code/Markdown/Raw
- Move up/down - Reorder cells
- Delete - Remove the cell
Connecting to a Kernel
Select Kernel
- Open a
.ipynbfile - Click Select Kernel in the top right
- Choose from available options:
- Python environments (conda, venv, pyenv)
- Remote kernels (JupyterHub, remote server)
- Existing Jupyter sessions
Create Virtual Environment
# Create a virtual environment
python -m venv venv
# Activate it
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Install packages
pip install jupyter numpy pandas matplotlib seaborn scikit-learn
Register Environment as Kernel
# Install ipykernel
pip install ipykernel
# Register the environment
python -m ipykernel install --user --name=myproject --display-name="Python (MyProject)"
AI-Assisted Data Analysis
Analyzing DataFrames
- Load your data in a code cell:
import pandas as pd
df = pd.read_csv('data.csv')
df.head()
- Run the cell to see the output
- Select the output table
- Right-click and choose Add to Chat (or use
@notebook) - Ask Cursor:
Analyze this dataset. What are the key patterns and insights?
Generating Visualizations
Create a visualization showing the relationship between column A and column B.
Use seaborn with a regression line and confidence interval.
Cursor will generate the code:
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 6))
sns.regplot(data=df, x='column_A', y='column_B', ci=95)
plt.title('Relationship Between A and B')
plt.show()
Exploratory Data Analysis (EDA)
Perform a complete EDA on this dataset including:
1. Data quality check (missing values, duplicates)
2. Descriptive statistics
3. Distribution plots for numeric columns
4. Correlation heatmap
5. Outlier detection
Using Cell Output as Context
Inline AI in Notebooks
- Run a cell that produces output (table, chart, etc.)
- Click the AI button in the cell toolbar
- Ask questions about the output:
What do these correlation values suggest about feature importance?
Notebook-Level Context
Use @notebook in chat to reference the entire notebook:
@notebook Review all the analysis so far and suggest the next steps for building a predictive model.
Advanced Features
Variable Inspector
- Run some cells to create variables
- Open the Variable Inspector:
- View > Appearance > Show Variable Inspector
- See all active variables, their types, and values
Debugging Notebooks
- Set breakpoints in code cells
- Click Debug Cell in the cell toolbar
- Step through execution with
F10/F11 - Inspect variables in the Debug sidebar
Exporting
| Format | Command |
|---|---|
| HTML | File > Export Notebook As > HTML |
| Python | File > Export Notebook As > Python Script |
| File > Export Notebook As > PDF | |
| Markdown | File > Export Notebook As > Markdown |
Best Practices
Organize Your Analysis
# Data Analysis Notebook
## 1. Setup
Import libraries and load data
## 2. Data Quality Check
Check for missing values, duplicates, and data types
## 3. Exploratory Analysis
Visualize distributions and relationships
## 4. Feature Engineering
Create new features and transform existing ones
## 5. Modeling
Build and evaluate predictive models
## 6. Conclusions
Summarize findings and recommendations
Use Markdown Cells for Documentation
- Explain the purpose of each section
- Document assumptions and decisions
- Add context for future readers
Clean Output Before Sharing
- Clear all outputs:
- Notebook menu > Clear All Outputs
- Restart kernel:
- Notebook menu > Restart Kernel
- Run all cells:
- Notebook menu > Run All
Troubleshooting
| Issue | Solution |
|---|---|
| Kernel won't start | Check Python path and virtual environment |
| Imports failing | Install packages in the correct environment |
| Output not displaying | Restart kernel and re-run cell |
| Notebook won't save | Check file permissions |
| AI not seeing cell output | Use @notebook or select output manually |
Example Workflow
# Cell 1: Setup
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Cell 2: Load Data
df = pd.read_csv('sales_data.csv')
print(f"Shape: {df.shape}")
df.head()
# Cell 3: Quick Profile
df.describe()
# Cell 4: Ask AI for insights
# Select output from Cell 3, then ask:
# "What patterns do you see in this data?"
# Cell 5: Visualization
plt.figure(figsize=(12, 6))
sns.lineplot(data=df, x='date', y='revenue')
plt.title('Revenue Over Time')
plt.show()