Code
# Example variables
x = 5
y = "Hello"
z = [1, 2, 3]
# These will appear in the Variable InspectorJupyterLab Basics: Variable Inspection, Magic Commands, and Shortcuts
Before we can use the Variable Inspector in JupyterLab, we need to install the extension. Follow these steps:
Start a new JupyterLab session in your web browser.
Click on the β+β button in the top left corner to open the Launcher (it might already be opened).
Under βOtherβ, click on βTerminalβ to open a new terminal session.
In the terminal, type the following command and press Enter:
pip install lckr-jupyterlab-variableinspectorWait for the installation to complete. You should see a message indicating successful installation.
Once the installation is complete, you need to restart JupyterLab for the changes to take effect. To do this:
https://workbench-1.bren.ucsb.edu again.After restarting JupyterLab, the Variable Inspector extension should be available for use.
Now that you have installed the Variable Inspector extension, hereβs how to use it:
Open the Variable Inspector: - Menu: View > Activate Command Palette, then type βvariable inspectorβ - Shortcut: Ctrl + Shift + I (Windows/Linux) or Cmd + Shift + I (Mac) - Right-click in an open notebook and select βOpen Variable Inspectorβ (will be at the bottom of the list)
The Variable Inspector shows: - Variable names - Types - Values/shapes - Count (for collections)
The variable inspector is not suitable for use with large dataframes or large arrays. You should use standard commands like df.head(), df.tail(), df.info(), df.describe() to inspect large dataframes.
Magic commands start with % (line magics) or %% (cell magics). Note that available magic commands may vary depending on your Jupyter environment and installed extensions.
Hello from the shell!
['bar_plots.html', 'bar_plots.qmd', 'chart_customization.qmd', 'comprehensions.qmd', 'control_flows.qmd', 'data_aggregation.html', 'data_aggregation.qmd', 'data_cleaning.html', 'data_cleaning.qmd', 'data_grouping.qmd', 'data_merging.html', 'data_merging.qmd', 'data_selection.qmd', 'dictionaries.html', 'dictionaries.qmd', 'first_steps.qmd', 'functions.html', 'functions.qmd', 'JupyterLab.qmd', 'JupyterLab.quarto_ipynb', 'lists.html', 'lists.qmd', 'matplotlib.html', 'matplotlib.qmd', 'numpy.html', 'numpy.qmd', 'ocean_temperatures.csv', 'output.csv', 'Pandas_Cheat_Sheet.pdf', 'pandas_dataframes.qmd', 'pandas_series.qmd', 'print.html', 'print.qmd', 'random_numbers.qmd', 'read_csv.qmd', 'seaborn.qmd', 'sets.qmd', 'setting_up_python.html', 'setting_up_python.qmd', 'timeseries.html', 'timeseries.qmd', 'workflow_methods.html', 'workflow_methods.qmd']
| Action | Windows/Linux | Mac |
|---|---|---|
| Run cell | Shift + Enter | Shift + Enter |
| Run cell and insert below | Alt + Enter | Option + Enter |
| Run cell and select below | Ctrl + Enter | Cmd + Enter |
| Enter command mode | Esc | Esc |
| Enter edit mode | Enter | Enter |
| Save notebook | Ctrl + S | Cmd + S |
| Insert cell above | A (in command mode) | A (in command mode) |
| Insert cell below | B (in command mode) | B (in command mode) |
| Cut cell | X (in command mode) | X (in command mode) |
| Copy cell | C (in command mode) | C (in command mode) |
| Paste cell | V (in command mode) | V (in command mode) |
| Undo cell action | Z (in command mode) | Z (in command mode) |
| Change to code cell | Y (in command mode) | Y (in command mode) |
| Change to markdown cell | M (in command mode) | M (in command mode) |
| Split cell at cursor | Ctrl + Shift + - | Cmd + Shift + - |
| Merge selected cells | Shift + M (in command mode) | Shift + M (in command mode) |
| Toggle line numbers | Shift + L (in command mode) | Shift + L (in command mode) |
| Toggle output | O (in command mode) | O (in command mode) |
? after a function name for more detailed help (e.g., print?)dir() to see available attributes/methods (e.g., dir(str))help() command to get information about functions and objects.