AI Assistant in Jupyter notebooks
Install the AI Assistant plugin
This functionality relies on the AI Assistant plugin, which you need to install and enable.
Press Ctrl+Alt+S to open settings and then select
.Open the Marketplace tab, find the AI Assistant plugin, and click Install (restart the IDE if prompted).
Use Jupyter-specific AI features in PyCharm to explain Jupyter cells and DataFrames, create new cells and visualizations, edit cells, and fix errors in your code.
Explain with AI
Explain Jupyter cell
Open a Jupyter notebook and do one of the following:
Right-click the cell to open the context menu.
Press Alt+Enter.
Select AI Actions and then Explain Code.
Select Jupyter Cell or Whole Jupyter File.
The AI Assistant tool window will open to provide a detailed description of the Jupyter file or selected cell.
Explain DataFrame
Click AI Actions in the upper-right corner of the output cell and select Explain DataFrame.
The AI Assistant tool window will open to provide a detailed description of the DataFrame.
Create cells and visualizations
Create code cell from snippet
You can create a new code cell with AI-generated code in your Jupyter notebook.
Open or create an .ipynb file.
Click Insert Snippet as Jupyter Cell in the upper-right corner of the field with the generated code.
Create AI cell
AI can create a new cell with AI-generated code based on your request.
Click the AI button in between cells.
Type your request in the AI Assistant input field and click Send or use AI suggestions.
AI Assistant will generate a code for the new cell:
Select
to add the code to the cell and run it as-is or to add the code to the cell and continue working on it.
Create visualizations
Click AI Actions in the upper-right corner of the output cell and select Generate Visualizations in Chat.
The AI Assistant tool window will open to provide AI-generated code snippets for several visualizations.
Select one of the following options:
Copy the suggested code to the clipboard.
Insert code into the editor at the caret position.
Create a new file from the snippet.
Create a new code cell from the snippet.
Edit cells
AI Assistant can help you modify existing cells.
Right-click the cell you want to edit.
Select AI Edit Cell from the context menu.
Type your request in the AI Assistant input field and click Send or use AI suggestions.
AI Assistant will generate new code.
Select
to add the code to the cell and run it as-is or to add the code to the cell and continue working on it.
Use AI suggestions
AI Assistant can analyze your notebook data and offer you a choice of prompts for code suggestions.
Click the Suggestions icon on the right side of an AI input field.
Choose one of the suggested prompts. The selected prompt, combined with notebook data sent for analysis, will be used for code generation.
Fix errors
When your notebook or cell execution fails with an error, the AI Fix Cell option appears in the context menu.
Right-click the cell you want to fix.
Select AI Fix Cell from the context menu.
AI Assistant will generate new code with the error fixed.
Select
to add the code to the cell and run it as-is or to add the code to the cell and continue working on it.