AI Assistant in Jupyter notebooks
Available only in PyCharm Professional: download to try or compare editions
This functionality relies on the AI Assistant plugin, which you need to install and enable.
Press CtrlAlt0S to open settings and then select Plugins.
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, generate visualizations, edit cells, and fix errors in your code.
Open a Jupyter notebook and do one of the following:
Right-click the cell to open the context menu.
Press AltEnter.
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.
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.
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.
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 Accept and Run to add the code to the cell and run it as-is or Accept to add the code to the cell and continue working on it.
AI Assistant can generate code snippets for data visualizations based on your dataframe.
Do one of the following:
Click AI Actions in the upper-right corner of the output cell and select Generate Visualizations in Chat.
Type
/plot
in AI Assistant chat and use#
to mention the dataframe.
AI Assistant will suggest 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 code cell from the snippet.
tip
You can specify the requirements for the visualization in chat, and AI Assistant will generate the code snippet for you.
For example, if you type
/plot #jupyter:df histogram of x column with legend and values
, AI Assistant will suggest a relevant code snippet.
AI Assistant can help you modify existing cells.
Place the caret anywhere in the cell you want to edit and press Ctrl0\.
Alternatively, right-click the cell and 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 Accept and Run to add the code to the cell and run it as-is or Accept to add the code to the cell and continue working on it.
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.
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 Accept and Run to add the code to the cell and run it as-is or Accept to add the code to the cell and continue working on it.
Thanks for your feedback!