{"id":1162,"date":"2025-09-12T12:26:11","date_gmt":"2025-09-12T10:26:11","guid":{"rendered":"https:\/\/web.cs.infn.it\/wordpress\/?p=1162"},"modified":"2025-09-12T13:20:27","modified_gmt":"2025-09-12T11:20:27","slug":"jupyter-notebook-tips-tricks-and-shortcuts","status":"publish","type":"post","link":"https:\/\/web.cs.infn.it\/wordpress\/2025\/09\/12\/jupyter-notebook-tips-tricks-and-shortcuts\/","title":{"rendered":"Jupyter Notebook Tips, Tricks, and Shortcuts"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2024\/05\/help-doc.png.webp\" alt=\"help-tab\" class=\"wp-image-48266\"\/><\/figure>\n\n\n\n<p>Jupyter Notebook is a must-have tool for anyone working with data, allowing you to write and run live code, display visuals, and mix in narrative text\u2014all in one interactive document. In this post, I\u2019ll share my favorite Jupyter Notebook tips, tricks, and shortcuts to help you work smarter and more efficiently.<\/p>\n\n\n\n<p>If you\u2019re just getting started, check out our <a href=\"https:\/\/www.dataquest.io\/blog\/jupyter-notebook-tutorial\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jupyter Notebook Tutorial for Beginners<\/a>, where you\u2019ll learn the basics and discover how to make the most of your notebooks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why Jupyter Notebook?<\/h3>\n\n\n\n<p>Whether you\u2019re a beginner or have been using Jupyter for years, you\u2019ll find useful tips here to speed up your workflow, troubleshoot errors, and improve your productivity. From essential keyboard shortcuts to advanced magic commands, we\u2019ve got something for everyone. Let\u2019s dive in!<\/p>\n\n\n\n<p><em>(This post is based on a post that originally appeared on <a href=\"https:\/\/arogozhnikov.github.io\/2016\/09\/10\/jupyter-features.html\" target=\"_blank\" rel=\"noreferrer noopener\">Alex Rogozhnikov&#8217;s blog, &#8216;Brilliantly Wrong&#8217;<\/a>. We\u2019ve expanded on it and will continue updating over time\u2014if you have a suggestion, <a href=\"https:\/\/twitter.com\/dataquestio\" target=\"_blank\" rel=\"noreferrer noopener\">let us know<\/a>. Thanks to Alex for graciously letting us republish his work.)<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/interface-screenshot.png\" alt=\"interface-screenshot\"\/><\/figure>\n\n\n\n<p><em>The Jupyter interface.<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Where Did Jupyter Notebook Come From?<\/h3>\n\n\n\n<p>Project Jupyter evolved from the original IPython project to support multiple languages, leading to its name as the Jupyter Notebook. The name itself is a nod to its initial focus on <strong>JU<\/strong>lia, <strong>PYT<\/strong>hon, and <strong>R<\/strong> (and is also inspired by the planet Jupiter).<\/p>\n\n\n\n<p>When running Python in Jupyter, the IPython kernel powers your notebooks, giving you access to features that make coding smoother and more interactive (we\u2019ll cover these soon!).<\/p>\n\n\n\n<p>Now, let\u2019s explore 28 practical tips to make your Jupyter experience smoother, faster, and more productive.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Jupyter Notebook Keyboard Shortcuts<\/h2>\n\n\n\n<p>As any power user knows, keyboard shortcuts can save you significant time. Jupyter Notebook provides a built-in reference for these shortcuts under <code>Help &gt; Keyboard Shortcuts<\/code> in the top menu. Alternatively, you can press <code>H<\/code> while in <strong>Command Mode<\/strong> to view the full list. It\u2019s a good idea to check this list periodically, as new shortcuts may be added with updates.<\/p>\n\n\n\n<p>Another helpful tool for navigating efficiently is the <strong>command palette<\/strong>, which can be accessed by pressing <code>Cmd + Shift + P<\/code> (or <code>Ctrl + Shift + P<\/code> on Windows and Linux). The command palette allows you to run any command by name, making it a useful alternative when you don\u2019t remember a shortcut or if the action you want doesn\u2019t have one. This functionality is similar to Spotlight search on a Mac, and once you get used to it, you\u2019ll wonder how you worked without it!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/command-palette.gif\" alt=\"command-palette\"\/><\/figure>\n\n\n\n<p><em>The command palette provides an efficient way to run commands without needing to remember specific keyboard shortcuts.<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Frequently Used Jupyter Notebook Keyboard Shortcuts:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Esc<\/code> switches you to <strong>Command Mode<\/strong>, where you can navigate around your notebook using the arrow keys. You&#8217;ll know you&#8217;re in <strong>Command Mode<\/strong> when the notebook&#8217;s cell border is blue, and no blinking text cursor is visible inside the cell.<\/li>\n\n\n\n<li>While in <strong>Command Mode<\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>A<\/code> inserts a new cell above the current cell, while <code>B<\/code> inserts one below.<\/li>\n\n\n\n<li><code>M<\/code> converts the current cell to a <strong>Markdown<\/strong> cell, and <code>Y<\/code> switches it back to a <strong>Code<\/strong> cell.<\/li>\n\n\n\n<li><code>D + D<\/code> (<em>press &#8220;D&#8221; twice<\/em>) deletes the selected cell.<\/li>\n\n\n\n<li><code>Z<\/code> undoes the deletion of a cell\u2014perfect if you delete one by mistake.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>Enter<\/code> switches you from <strong>Command Mode<\/strong> back to <strong>Edit Mode<\/strong>. In <strong>Edit Mode<\/strong>, the cell border turns green, and a blinking text cursor appears inside, allowing you to edit its content.<\/li>\n\n\n\n<li>While in <strong>Edit Mode<\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>Shift + Enter<\/code> runs the cell and moves to the next one.<\/li>\n\n\n\n<li><code>Ctrl + Enter<\/code> runs the cell but keeps the focus on the same cell.<\/li>\n\n\n\n<li><code>Alt + Enter<\/code> runs the cell and inserts a new one below.<\/li>\n\n\n\n<li><code>Ctrl + ]<\/code> indents the selected lines, and <code>Ctrl + [<\/code> unindents them.<\/li>\n\n\n\n<li><code>Ctrl + \/<\/code> toggles comments for selected lines of code.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>Ctrl + Shift + -<\/code> splits the current cell into two at the cursor\u2019s location.<\/li>\n\n\n\n<li><code>Esc + F<\/code> opens the <strong>Find and Replace<\/strong> dialog, allowing you to search and replace within the code cells without affecting outputs.<\/li>\n\n\n\n<li><code>Esc + O<\/code> toggles the output visibility of the current cell.<\/li>\n\n\n\n<li>Selecting Multiple Cells:\n<ul class=\"wp-block-list\">\n<li><code>Shift + J<\/code> (<em>or<\/em> <code>Shift + Down<\/code>) selects the next cell downward.<br><code>Shift + K<\/code> (<em>or<\/em> <code>Shift + Up<\/code>) selects the next cell upward.<\/li>\n\n\n\n<li>Once multiple cells are selected, you can delete, copy, cut, paste, or run them as a batch\u2014making it easier to manage and reorganize your notebook.<\/li>\n\n\n\n<li><code>Shift + M<\/code> merges selected cells into one.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/multi-merge.gif\" alt=\"multi-merge\"\/><\/figure>\n\n\n\n<p><em>Merging multiple cells.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Display Multiple Outputs in Jupyter Notebook Cells<\/h2>\n\n\n\n<p>By default, Jupyter Notebook only displays the output of the last command within a cell. For example, in the code below, only the output of <code>quakes.tail(3)<\/code> is shown:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pydataset import data\n\nquakes = data('quakes')\nquakes.head(3)  # Output is not displayed\nquakes.tail(3)  # Output is displayed\n<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>lat<\/th><th>long<\/th><th>depth<\/th><th>mag<\/th><th>stations<\/th><\/tr><\/thead><tbody><tr><td>-25.93<\/td><td>179.54<\/td><td>470<\/td><td>4.4<\/td><td>22<\/td><\/tr><tr><td>-12.28<\/td><td>167.06<\/td><td>248<\/td><td>4.7<\/td><td>35<\/td><\/tr><tr><td>-20.13<\/td><td>184.20<\/td><td>244<\/td><td>4.5<\/td><td>34<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>However, you can change this behavior to display all outputs by using the following Jupyter Notebook trick:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from IPython.core.interactiveshell import InteractiveShell\nfrom pydataset import data\n\nInteractiveShell.ast_node_interactivity = \"all\"\n\nquakes = data('quakes')\nquakes.head(3)  # Output is displayed\nquakes.tail(3)  # Output is displayed\n<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>First 3 rows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>lat<\/th><th>long<\/th><th>depth<\/th><th>mag<\/th><th>stations<\/th><\/tr><\/thead><tbody><tr><td>-20.42<\/td><td>181.62<\/td><td>562<\/td><td>4.8<\/td><td>41<\/td><\/tr><tr><td>-20.62<\/td><td>181.03<\/td><td>650<\/td><td>4.2<\/td><td>15<\/td><\/tr><tr><td>-26.00<\/td><td>184.10<\/td><td>42<\/td><td>5.4<\/td><td>43<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Last 3 rows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>lat<\/th><th>long<\/th><th>depth<\/th><th>mag<\/th><th>stations<\/th><\/tr><\/thead><tbody><tr><td>-25.93<\/td><td>179.54<\/td><td>470<\/td><td>4.4<\/td><td>22<\/td><\/tr><tr><td>-12.28<\/td><td>167.06<\/td><td>248<\/td><td>4.7<\/td><td>35<\/td><\/tr><tr><td>-20.13<\/td><td>184.20<\/td><td>244<\/td><td>4.5<\/td><td>34<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If you want this behavior to persist across all your Jupyter environments (Notebook and Console), you can configure it by creating a file at <code>~\/.ipython\/profile_default\/ipython_config.py<\/code> with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>c = get_config()\n# Display all outputs in the cell\nc.InteractiveShell.ast_node_interactivity = \"all\"\n<\/code><\/pre>\n\n\n\n<p>This configuration change can be especially useful when working with <code>pandas<\/code> DataFrames or when you need to compare multiple outputs in the same cell. It\u2019s one of the many Jupyter Notebook tricks that can help you optimize your workflow and enhance productivity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Easy Access to Documentation<\/h2>\n\n\n\n<p>Jupyter Notebook provides several ways to access documentation without leaving the interface, making it easy to get help when you need it. One option is through the <strong>Help<\/strong> menu, which includes links to online documentation for popular libraries like NumPy, pandas, SciPy, and Matplotlib.<\/p>\n\n\n\n<p><em>Access library documentation through the Help menu.<\/em><\/p>\n\n\n\n<p>Another useful method is using the built-in Docstring feature to view documentation for specific functions, methods, or variables. To do this, simply prepend the object with a question mark (<code>?<\/code>) and run the cell.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>?str.replace<\/code><\/pre>\n\n\n\n<p>The output will display the Docstring, explaining the syntax and functionality of the object:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Docstring:\nS.replace(old, new&#91;, count]) -&gt; str\n\nReturn a copy of S with all occurrences of substring\nold replaced by new. If the optional argument count is\ngiven, only the first count occurrences are replaced.\nType:      method_descriptor\n<\/code><\/pre>\n\n\n\n<p>This feature is especially useful for quickly checking parameters and return types, saving you time as you work through your Jupyter Notebook.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Plotting in Notebooks<\/h2>\n\n\n\n<p>Jupyter Notebook supports several powerful libraries for creating both static and interactive visualizations directly within your notebook. Here\u2019s a quick overview of popular options and when to use them:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/matplotlib.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Matplotlib<\/a>: The go-to plotting library in Python. Activate inline plots using <code>%matplotlib inline<\/code>. For a guided introduction, check out this <a href=\"https:\/\/www.dataquest.io\/blog\/matplotlib-tutorial\/\" target=\"_blank\" rel=\"noreferrer noopener\">Matplotlib Tutorial<\/a>.<\/li>\n\n\n\n<li><code>%matplotlib notebook<\/code>: Provides interactive plots with zooming and panning. However, rendering may be slower since it\u2019s processed server-side.<\/li>\n\n\n\n<li><a href=\"https:\/\/seaborn.pydata.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Seaborn<\/a>: Built on top of Matplotlib, Seaborn simplifies creating elegant and informative visualizations. Just importing Seaborn will automatically enhance your Matplotlib plots.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/mpld3\/mpld3\" target=\"_blank\" rel=\"noreferrer noopener\">mpld3<\/a>: Offers an alternative to Matplotlib using the d3.js library for interactive visualizations. Note that it has limited functionality compared to Matplotlib.<\/li>\n\n\n\n<li><a href=\"https:\/\/bokeh.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bokeh<\/a>: Ideal for building interactive plots with dynamic features such as zooming, filtering, and live updates, making it a popular choice for creating dashboards.<\/li>\n\n\n\n<li><a href=\"https:\/\/plotly.com\/python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Plotly<\/a>: Known for producing high-quality interactive visualizations. Fully open source, Plotly supports hover tooltips, legends, and a variety of chart types.<\/li>\n\n\n\n<li><a href=\"https:\/\/altair-viz.github.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Altair<\/a>: A declarative visualization library that emphasizes simplicity and elegance. While easy to use, its customization options are more limited compared to Matplotlib.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/bokeh.png\" alt=\"bokeh-plot-example\"\/><\/figure>\n\n\n\n<p><em>An example of an interactive Bokeh plot embedded within Jupyter.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. IPython Magic Commands<\/h2>\n\n\n\n<p>Jupyter Notebook is built on the IPython kernel, giving you access to a wide range of powerful <strong>IPython Magic commands<\/strong>. These commands can enhance productivity and simplify your workflow, providing shortcuts for common tasks like plotting, system calls, and debugging.<\/p>\n\n\n\n<p>To view all available magic commands, run the following in a cell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%lsmagic<\/code><\/pre>\n\n\n\n<p>This will display a list of both line magics (which operate on a single line) and cell magics (which affect entire cells):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Available line magics:\n%alias  %alias_magic  %autoawait  %autocall  %automagic  %autosave  %bookmark  %cat  %cd  %clear  %colors  %conda  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %man  %matplotlib  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %pip  %popd  %pprint  %precision  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %save  %sc  %set_env  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode\n\nAvailable cell magics:\n%%!  %%HTML  %%SVG  %%bash  %%capture  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%markdown  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile\n<\/code><\/pre>\n\n\n\n<p>Magic commands can be incredibly useful for tasks like debugging, profiling, or interacting with the system. If you\u2019re new to magics, check out the <a href=\"https:\/\/ipython.readthedocs.io\/en\/stable\/interactive\/magics.html\" target=\"_blank\" rel=\"noreferrer noopener\">official IPython Magic documentation<\/a> for examples and explanations.<\/p>\n\n\n\n<p>Stay tuned\u2014we\u2019ll highlight some of the most useful IPython magic commands in the upcoming sections to help you work more efficiently in your notebooks!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. IPython Magic \u2013 <code>%env<\/code>: Set Environment Variables<\/h2>\n\n\n\n<p>When working with libraries like Theano or TensorFlow in Jupyter Notebook, you may need to adjust environment variables to control their behavior. Instead of restarting the Jupyter server every time you modify an environment variable, you can use the <code>%env<\/code> magic command to manage them directly within your notebook.<\/p>\n\n\n\n<p>To list all current environment variables, simply run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%env<\/code><\/pre>\n\n\n\n<p>To set an environment variable, use the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%env VARIABLE_NAME=value<\/code><\/pre>\n\n\n\n<p>For example, to set the <code>OMP_NUM_THREADS<\/code> environment variable to 4, you would run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%env OMP_NUM_THREADS=4<\/code><\/pre>\n\n\n\n<p>To confirm the value has been set, you can access it using Python\u2019s <code>os.environ<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nos.environ&#91;'OMP_NUM_THREADS']<\/code><\/pre>\n\n\n\n<p>This will output the value of the variable, verifying that it\u2019s been set correctly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'4'<\/code><\/pre>\n\n\n\n<p>By using <code>%env<\/code>, you can quickly fine-tune your environment on the fly, making it especially useful when optimizing library performance or testing different configurations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. IPython Magic \u2013 <code>%run<\/code>: Reuse and Execute External Code<\/h2>\n\n\n\n<p>The <code>%run<\/code> magic command allows you to execute external Python files or entire Jupyter Notebooks directly within your current notebook. This is especially useful when you want to reuse code from previous projects without copying and pasting it into multiple notebooks.<\/p>\n\n\n\n<p>To execute a Python script, provide the path to the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%run path\/to\/your\/script.py<\/code><\/pre>\n\n\n\n<p>To run another Jupyter Notebook, specify the path to the <code>.ipynb<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%run path\/to\/your\/notebook.ipynb<\/code><\/pre>\n\n\n\n<p>For example, to execute a notebook named <code>two_histograms.ipynb<\/code> in the same directory as your current notebook, you would run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%run .\/two_histograms.ipynb<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/two-hists.png\" alt=\"two-hists\"\/><\/figure>\n\n\n\n<p>Keep in mind that <code>%run<\/code> executes the code in the current namespace, meaning variables and functions defined in the external file or notebook will be directly accessible in your current notebook. This is different from importing a module, where you typically need to use the module\u2019s name as a prefix to access its functions and variables.<\/p>\n\n\n\n<p>Using <code>%run<\/code> can help streamline your workflow and keep your projects organized by separating reusable code into external scripts or notebooks. This is one of the many useful Jupyter Notebook tips that can improve your productivity and reduce code duplication.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. IPython Magic \u2013 <code>%load<\/code>: Insert Code from External Scripts<\/h2>\n\n\n\n<p>The <code>%load<\/code> magic command allows you to insert code from an external script directly into a cell of your Jupyter Notebook. This is useful when you want to quickly import and run code from a file without needing to copy and paste it manually.<\/p>\n\n\n\n<p>To use <code>%load<\/code>, provide the path to the script you want to insert:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%load path\/to\/your\/script.py<\/code><\/pre>\n\n\n\n<p>For example, if you have a file named <code>hello_world.py<\/code> in the same directory as your notebook, you can load its code using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%load .\/hello_world.py<\/code><\/pre>\n\n\n\n<p>After running the cell, you\u2019ll see that the contents of <code>hello_world.py<\/code> are automatically inserted into the cell, replacing the <code>%load<\/code> line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if __name__ == \"__main__\":\n    print(\"Hello World!\")\n<\/code><\/pre>\n\n\n\n<p>When you execute the cell, you\u2019ll get the following output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello World!<\/code><\/pre>\n\n\n\n<p>In addition to local files, you can also use <code>%load<\/code> with URLs to insert code from online sources, making it even more versatile when working with external resources.<\/p>\n\n\n\n<p>This Jupyter Notebook tip highlights how the <code>%load<\/code> magic command can save time by quickly integrating external scripts into your notebook, helping you work more efficiently.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. IPython Magic \u2013 <code>%store<\/code>: Pass Variables Between Notebooks<\/h2>\n\n\n\n<p>The <code>%store<\/code> magic command lets you pass variables between different notebooks, making it extremely useful for multi-notebook workflows and collaborative projects. Instead of manually copying values, you can easily share data across notebooks with just a few commands.<\/p>\n\n\n\n<p>To store a variable for use in another notebook, use <code>%store<\/code> followed by the variable name:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data = 'this is the string I want to pass to a different notebook'\n%store data<\/code><\/pre>\n\n\n\n<p>You\u2019ll see confirmation that the variable has been stored:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Stored 'data' (str)<\/code><\/pre>\n\n\n\n<p>After storing it, you can optionally remove the variable from the current notebook\u2019s memory using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>del data<\/code><\/pre>\n\n\n\n<p>In another notebook, retrieve the stored variable using <code>%store -r<\/code> followed by the variable name:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%store -r data\nprint(data)<\/code><\/pre>\n\n\n\n<p>The output will confirm the value of the retrieved variable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>this is the string I want to pass to a different notebook<\/code><\/pre>\n\n\n\n<p>With the <code>%store<\/code> magic command, you can effortlessly share variables between notebooks, simplifying workflows and enhancing collaboration on large projects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">10. IPython Magic \u2013 <code>%who<\/code>: List Variables in the Global Scope<\/h2>\n\n\n\n<p>The <code>%who<\/code> magic command allows you to list all variables currently in the global scope. This is especially useful when you\u2019re working with many variables and need to see their names and types at a glance.<\/p>\n\n\n\n<p>To display all variables in the global scope, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%who<\/code><\/pre>\n\n\n\n<p>This will list all variables, regardless of their type.<\/p>\n\n\n\n<p>If you only want to display variables of a specific type, you can pass the type as an argument to <code>%who<\/code>. For example, to see only string variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>one = \"for the money\"\ntwo = \"for the show\"\nthree = \"to get ready now go cat go\"\n\n%who str<\/code><\/pre>\n\n\n\n<p>The output will list all string variables currently in the global scope:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>one  three  two<\/code><\/pre>\n\n\n\n<p>The <code>%who<\/code> magic command is a valuable Jupyter Notebook trick that helps you keep track of your variables, making it easier to maintain an organized and efficient coding environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">11. IPython Magic \u2013 <code>%timeit<\/code>: Timing Code Execution<\/h2>\n\n\n\n<p>When your code is running slowly, timing its execution can help you identify bottlenecks and optimize performance. The <code>%%time<\/code> and <code>%timeit<\/code> magic commands are two powerful tools for this purpose.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>%%time<\/code>: Measure Execution Time for a Single Run<\/h3>\n\n\n\n<p>The <code>%%time<\/code> magic command measures the time taken to execute all the code in a cell and displays the CPU times and total elapsed time (wall time).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%%time\nimport time\n\nfor _ in range(1000):\n    time.sleep(0.01)  # sleep for 0.01 seconds\n<\/code><\/pre>\n\n\n\n<p>The output will show detailed timing information:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CPU times: user 21.5 ms, sys: 14.8 ms, total: 36.3 ms\nWall time: 11.6 s<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><code>%timeit<\/code>: Measure Execution Time Across Multiple Runs<\/h3>\n\n\n\n<p>The <code>%timeit<\/code> magic command provides a more accurate performance measurement by executing the code multiple times (the default is 100,000 loops) and displaying the mean of the fastest runs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\n\n%timeit np.random.normal(size=100)\n<\/code><\/pre>\n\n\n\n<p>The output will include timing statistics:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>9.29 \u00b5s \u00b1 63.1 ns per loop (mean \u00b1 std. dev. of 7 runs, 100000 loops each)<\/code><\/pre>\n\n\n\n<p>These Jupyter Notebook tips highlight how using <code>%%time<\/code> and <code>%timeit<\/code> can help you measure performance, pinpoint inefficiencies, and optimize your code for faster execution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">12. IPython Magic \u2013 <code>%config<\/code>: High-Resolution Plot Outputs for Retina Displays<\/h2>\n\n\n\n<p>When working on devices with high-resolution Retina displays, such as recent MacBook models, you might notice that plots generated in Jupyter Notebook look pixelated or blurry. Fortunately, with a simple IPython magic command, you can create double-resolution plots that take full advantage of your screen&#8217;s capabilities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Sample Plot<\/h3>\n\n\n\n<p>Let\u2019s start by generating a basic plot using Matplotlib:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import matplotlib.pyplot as plt\n\nx = range(1000)\ny = &#91;i ** 2 for i in x]\nplt.plot(x, y)\nplt.show()\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/hires-1.png\" alt=\"hires-1\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Enable High-Resolution Plotting<\/h3>\n\n\n\n<p>To display sharper plots on Retina displays, use the following magic command before your plotting code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%config InlineBackend.figure_format = 'retina'\n\nplt.plot(x, y)\nplt.show()\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/hires-2.png\" alt=\"hires-2\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Key Considerations<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Retina displays only:<\/strong> The high-resolution plot will only be visible on Retina displays. On standard displays, the plot will render at normal resolution.<\/li>\n\n\n\n<li><strong>Better visualization:<\/strong> By setting <code>InlineBackend.figure_format<\/code> to <code>'retina'<\/code>, Matplotlib generates plots with double the resolution, leading to sharper and more detailed visuals on supported devices.<\/li>\n<\/ul>\n\n\n\n<p>This Jupyter Notebook tip demonstrates how a small configuration change can significantly improve the visual quality of your plots, making them look crisp and professional on high-resolution displays.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">13. IPython Magic \u2013 <code>%pdb<\/code>: Debugging Your Code<\/h2>\n\n\n\n<p>The <code>%pdb<\/code> magic command lets you debug your code using the Python Debugger (<code>pdb<\/code>) directly within the Jupyter Notebook. This tip demonstrates how you can efficiently catch errors and inspect variables without leaving the notebook interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to Use <code>%pdb<\/code><\/h3>\n\n\n\n<p>Let\u2019s say you have a function that calculates the average of a list of numbers but fails if the list is empty:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%pdb\n\ndef calculate_average(numbers):\n    total = sum(numbers)\n    count = len(numbers)\n    return total \/ count  # This will raise ZeroDivisionError if the list is empty\n\n# Call the function with an empty list to trigger the error\ncalculate_average(&#91;])\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">What Happens When an Exception Is Raised?<\/h3>\n\n\n\n<p>When the exception occurs, Jupyter automatically enters the <code>pdb<\/code> debugger. You\u2019ll be able to examine the current state of the program, step through the code, and inspect variables to identify the issue.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Common <code>pdb<\/code> Commands<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>n<\/code> (next):<\/strong> Execute the next line of code.<\/li>\n\n\n\n<li><strong><code>s<\/code> (step):<\/strong> Step into a function call.<\/li>\n\n\n\n<li><strong><code>c<\/code> (continue):<\/strong> Continue execution until the next breakpoint or exception.<\/li>\n\n\n\n<li><strong><code>p var<\/code> (print):<\/strong> Display the value of a variable named <code>var<\/code>.<\/li>\n\n\n\n<li><strong><code>h<\/code> (help):<\/strong> Display a list of <code>pdb<\/code> commands and their descriptions.<\/li>\n\n\n\n<li><strong><code>q<\/code> (quit):<\/strong> Exit the debugger.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Why Use <code>%pdb<\/code>?<\/h3>\n\n\n\n<p>Debugging directly in the notebook allows for an interactive and efficient workflow. By using <code>%pdb<\/code>, you can quickly identify and fix issues without needing to switch to an external debugger, saving time and effort when developing and testing your code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">14. Suppress the Output of a Final Function<\/h2>\n\n\n\n<p>Sometimes, when working in Jupyter Notebooks, you may notice that the output of a function appears alongside visualizations, like when using plotting libraries such as Matplotlib. This Jupyter Notebook trick allows you to suppress that extra output, keeping your notebook clean and focused.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Understanding the Issue<\/h3>\n\n\n\n<p>Let\u2019s create a sample plot using Matplotlib:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%matplotlib inline\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.linspace(0, 1, 1000)**1.5\nplt.hist(x)\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/hist.png\" alt=\"hist\"\/><\/figure>\n\n\n\n<p>In addition to the histogram plot, the cell outputs extra information related to the <code>plt.hist(x)<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(array(&#91;216., 126., 106.,  95.,  87.,  81.,  77.,  73.,  71.,  68.]),\n array(&#91;0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ]),\n &lt;a list of 10 Patch objects&gt;)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Solution: Suppress Output Using a Semicolon<\/h3>\n\n\n\n<p>To hide the extra output and display only the plot, add a semicolon (<code>;<\/code>) at the end of the function call:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plt.hist(x);\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/hist.png\" alt=\"hist\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Why It Works<\/h3>\n\n\n\n<p>The semicolon suppresses the function\u2019s return value from being displayed in the output cell, leaving only the plot visible. This simple Jupyter Notebook trick helps maintain a clean and professional notebook, especially when working with multiple plots or functions that produce verbose output.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">15. Executing Shell Commands<\/h2>\n\n\n\n<p>Jupyter Notebook allows you to execute shell commands directly within cells, making it easier to manage files, install packages, and interact with the system without switching to an external terminal. This is done by prefixing the shell command with an exclamation mark (<code>!<\/code>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Listing Files in the Directory<\/h3>\n\n\n\n<p>To list all CSV files in your current working directory, use the <code>ls<\/code> command with a wildcard (<code>*<\/code>) to match the file extension:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!ls *.csv<\/code><\/pre>\n\n\n\n<p>The output will display the list of matching files:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nba_2016.csv titanic.csv pixar_movies.csv whitehouse_employees.csv<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Installing and Verifying Packages<\/h3>\n\n\n\n<p>You can install Python packages using the shell within the notebook and then verify the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install numpy\n!pip list | grep pandas<\/code><\/pre>\n\n\n\n<p>The output will confirm the package installation and display the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Requirement already satisfied: numpy in \/dataquest\/system\/env\/python3\/lib\/python3.8\/site-packages (1.24.4)\npandas              2.0.3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why Use Shell Commands?<\/h3>\n\n\n\n<p>Shell commands in Jupyter streamline your workflow by letting you perform system-level tasks, manage files, and handle package installations all within the same notebook. This keeps your work centralized and allows for better project organization and reproducibility.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">16. Using LaTeX for Formulas<\/h2>\n\n\n\n<p>One of my most favorite Jupyter Notebook tricks is the ability to embed beautifully rendered mathematical formulas using <strong>LaTeX<\/strong> within <strong>Markdown<\/strong> cells.<\/p>\n\n\n\n<p>LaTeX is a typesetting language designed for creating well-structured documents, but it&#8217;s particularly loved by mathematicians and scientists for its ability to render beautiful mathematical expressions. Instead of relying on plain text shortcuts to represent equations, LaTeX allows you to display mathematical symbols exactly as you\u2019d remember them from math class\u2014like the elegant summation or integral<\/p>\n\n\n\n<p>symbols. This makes your equations not only more visually appealing but also easier for others to understand at a glance.<\/p>\n\n\n\n<p>There are two main ways to use LaTeX:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Inline Math Mode:<\/strong> Use single dollar signs (<code>$...$<\/code>) to embed mathematical expressions directly within a line of text.<\/li>\n\n\n\n<li><strong>Display Math Mode:<\/strong> Use double dollar signs (<code>$$...$$<\/code>) to center the expression and display it on its own line with larger formatting.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Literal LaTeX Input<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Euler's identity (inline): $e^{i\\pi} + 1 = 0$\nEuler's identity (display):\n$$\ne^{i\\pi} + 1 = 0\n$$\n\nPythagorean theorem (inline): $a^2 + b^2 = c^2$\nPythagorean theorem (display):\n$$\na^2 + b^2 = c^2\n$$\n\nSummation (inline): $\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}$\nSummation (display):\n$$\n\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}\n$$\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Rendered Output<\/h3>\n\n\n\n<p>Euler&#8217;s identity (inline):<\/p>\n\n\n\n<p>Euler&#8217;s identity (display):<\/p>\n\n\n\n<p>Pythagorean theorem (inline):<\/p>\n\n\n\n<p>Pythagorean theorem (display):<\/p>\n\n\n\n<p>Summation (inline):<\/p>\n\n\n\n<p>Summation (display):<\/p>\n\n\n\n<p>By leveraging Markdown and LaTeX together, you can communicate complex mathematical concepts effectively. For more advanced equations and symbols, explore this <a href=\"https:\/\/gitmind.com\/faq\/formula-list.html\" target=\"_blank\" rel=\"noreferrer noopener\">LaTeX reference guide<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">17. Run Code from Different Kernels in a Notebook<\/h2>\n\n\n\n<p>One of the most versatile Jupyter Notebook tricks I use is the ability to run code from multiple programming languages (or kernels) within a single notebook. This allows me to combine the strengths of different languages seamlessly, making my notebooks more powerful and efficient.<\/p>\n\n\n\n<p>To use a specific kernel in a cell, prefix it with the corresponding IPython magic command:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>%%bash<\/code> for Bash shell scripts<\/li>\n\n\n\n<li><code>%%HTML<\/code> for HTML code<\/li>\n\n\n\n<li><code>%%python2<\/code> for Python 2<\/li>\n\n\n\n<li><code>%%python3<\/code> for Python 3<\/li>\n\n\n\n<li><code>%%ruby<\/code> for Ruby<\/li>\n\n\n\n<li><code>%%perl<\/code> for Perl<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Running Bash Commands<\/h3>\n\n\n\n<p>The <code>%%bash<\/code> magic command lets you execute Bash commands directly within a notebook cell. Here&#8217;s an example that prints a sequence of numbers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%%bash\nfor i in {1..5}\ndo\n  echo \"i is $i\"\ndone\n<\/code><\/pre>\n\n\n\n<p>The output will display:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>i is 1\ni is 2\ni is 3\ni is 4\ni is 5\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Running Ruby Code<\/h3>\n\n\n\n<p>You can also execute Ruby code using the <code>%%ruby<\/code> magic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%%ruby\nputs \"Hello from Ruby!\"\n(1..5).each do |i|\n  puts \"Square of #{i} is #{i**2}\"\nend\n<\/code><\/pre>\n\n\n\n<p>The output will be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello from Ruby!\nSquare of 1 is 1\nSquare of 2 is 4\nSquare of 3 is 9\nSquare of 4 is 16\nSquare of 5 is 25\n<\/code><\/pre>\n\n\n\n<p>This Jupyter Notebook magic command highlights the flexibility of the platform, allowing you to combine different languages in one environment. This can be particularly helpful when you need to perform tasks like shell scripting, web scraping, or data processing using specialized tools across multiple languages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">18. Install Other Kernels for Jupyter<\/h2>\n\n\n\n<p>One of Jupyter\u2019s standout features is its ability to support multiple kernels, allowing you to run notebooks in different programming languages such as R, Julia, and more. This Jupyter Notebook tip walks you through the steps to install an R kernel using two methods.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Option 1: Installing the R Kernel Using Anaconda (Easiest Method)<\/h3>\n\n\n\n<p>If you set up your environment using Anaconda, installing the R kernel is straightforward. Simply run the following command in your terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conda install -c r r-essentials\n<\/code><\/pre>\n\n\n\n<p>The <code>r-essentials<\/code> package includes everything you need to start working with R in Jupyter, including the IRkernel and several popular R packages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Option 2: Installing the R Kernel Manually<\/h3>\n\n\n\n<p>If you\u2019re not using Anaconda, you\u2019ll need to install R manually from <a href=\"https:\/\/cloud.r-project.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">CRAN<\/a>. Once R is installed, open an R console and run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>install.packages(c('repr', 'IRdisplay', 'crayon', 'pbdZMQ', 'devtools'))\ndevtools::install_github('IRkernel\/IRkernel')\nIRkernel::installspec()  # Register the kernel in the current R installation\n<\/code><\/pre>\n\n\n\n<p>These commands will install the necessary dependencies and register the IRkernel with Jupyter, making it available as an option when creating new notebooks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using Other Kernels<\/h3>\n\n\n\n<p>In addition to R, Jupyter supports many other kernels, such as Julia, Scala, and more. For a complete list of supported kernels and installation instructions, check out the <a href=\"https:\/\/jupyter.readthedocs.io\/en\/latest\/install-kernel.html\" target=\"_blank\" rel=\"noreferrer noopener\">official Jupyter documentation<\/a>.<\/p>\n\n\n\n<p>By installing additional kernels, you can make Jupyter a truly multi-language environment, allowing you to work seamlessly across different programming languages within the same interface.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">19. IPython Magic \u2013 <code>%load_ext<\/code>: Enable and Manage Extensions<\/h2>\n\n\n\n<p>The <code>%load_ext<\/code> magic command lets you enable extensions that provide additional functionalities within Jupyter notebooks. These extensions can be useful for debugging, formatting, or profiling your code, among other tasks.<\/p>\n\n\n\n<p>To load an extension, simply specify its name:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%load_ext extension_name<\/code><\/pre>\n\n\n\n<p>For example, to load the <code>autoreload<\/code> extension, which automatically reloads modules before executing cells, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%load_ext autoreload<\/code><\/pre>\n\n\n\n<p>You can then configure the extension. For example, to automatically reload all modules before each execution:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%autoreload 2<\/code><\/pre>\n\n\n\n<p>If you no longer need the extension during the session, you can disable it using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%unload_ext extension_name<\/code><\/pre>\n\n\n\n<p>The <code>%load_ext<\/code> magic command simplifies enabling extensions, enhancing your workflow and allowing you to customize Jupyter notebooks with additional tools tailored to your needs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">20. Writing Functions in Other Languages<\/h2>\n\n\n\n<p>Sometimes, the speed of <code>numpy<\/code> just isn\u2019t good enough for certain tasks, and I need to implement faster code. Sure, you could compile functions into dynamic libraries and manually write Python wrappers\u2026 but isn\u2019t it much better when this boring part is done for you?<\/p>\n\n\n\n<p>Fortunately, Jupyter makes it easy to write functions in Cython or Fortran and use them directly in your Python code. Here\u2019s how to get started:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Writing Functions with Cython<\/h3>\n\n\n\n<p>First, install the necessary packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install cython fortran-magic\n<\/code><\/pre>\n\n\n\n<p>Next, load the Cython extension into your notebook:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%load_ext Cython\n<\/code><\/pre>\n\n\n\n<p>You can now write Cython functions using the <code>%%cython<\/code> cell magic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%%cython\n\ndef multiply_by_2(float x):\n    return 2.0 * x\n<\/code><\/pre>\n\n\n\n<p>To test the function, pass a value and see the result:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>multiply_by_2(23.0)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Writing Functions with Fortran<\/h3>\n\n\n\n<p>Personally, I prefer using Fortran when writing number-crunching functions. I\u2019ve found it to be really convenient, especially for scientific computing tasks. To get started, load the Fortran magic extension:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%load_ext fortranmagic\n<\/code><\/pre>\n\n\n\n<p>You can now write Fortran subroutines directly in your notebook using the <code>%%fortran<\/code> cell magic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%%fortran\nsubroutine compute_fortran(x, y, z)\n    real, intent(in) :: x(:), y(:)\n    real, intent(out) :: z(size(x, 1))\n    z = sin(x + y)\nend subroutine compute_fortran\n<\/code><\/pre>\n\n\n\n<p>To test the subroutine, pass arrays and view the output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>compute_fortran(&#91;1, 2, 3], &#91;4, 5, 6])\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Additional Resources and Tips<\/h3>\n\n\n\n<p>If you\u2019d like to dive deeper into using Fortran with Python, I highly recommend checking out <a href=\"https:\/\/arogozhnikov.github.io\/2015\/11\/29\/using-fortran-from-python.html\" target=\"_blank\" rel=\"noreferrer noopener\">this detailed guide<\/a>. It walks you through how to get the most out of Fortran when writing high-performance code.<\/p>\n\n\n\n<p>There are also different just-in-time (JIT) compilation tools that can speed up your Python code. For example, <a href=\"https:\/\/arogozhnikov.github.io\/2015\/09\/08\/SpeedBenchmarks.html\" target=\"_blank\" rel=\"noreferrer noopener\">this speed benchmark guide<\/a> compares various methods and can help you decide which one works best for your needs.<\/p>\n\n\n\n<p>With tools like Cython and Fortran, you can optimize your code for high performance without the headache of writing complex wrappers. I\u2019ve personally found these techniques to be lifesavers when working on projects involving large datasets and intensive computations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">21. Multicursor Support<\/h2>\n\n\n\n<p>Jupyter Notebooks support multiple cursors, a feature similar to what you\u2019d find in code editors like Sublime Text or VS Code. This can be a game-changer when editing repetitive code or making bulk changes within cells.<\/p>\n\n\n\n<p>To enable multicursor mode, simply click and drag your mouse while holding down <code>Alt<\/code> (or <code>Option<\/code> on macOS).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/multiline.gif\" alt=\"multiline\"\/><\/figure>\n\n\n\n<p><em>Multicursor support in action.<\/em><\/p>\n\n\n\n<p>Alternatively, you can hold down <code>Ctrl<\/code> (or <code>Cmd<\/code> on macOS) and click at multiple locations within the cell to create cursors exactly where you need them. This method gives you precise control, which is especially useful when working with large blocks of code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">22. Jupyter-contrib Extensions<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/ipython-contrib\/jupyter_contrib_nbextensions\" target=\"_blank\" rel=\"noreferrer noopener\">Jupyter-contrib extensions<\/a> are a collection of community-driven enhancements that add extra functionality to Jupyter Notebooks. Some popular extensions include a spell-checker, code formatter, table of contents generator, and more. These extensions can significantly boost productivity and streamline your notebook workflow.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing Jupyter-contrib Extensions<\/h3>\n\n\n\n<p>To install these extensions and the configurator menu, which lets you browse and enable them from the Jupyter interface, run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install https:\/\/github.com\/ipython-contrib\/jupyter_contrib_nbextensions\/tarball\/master\n!pip install jupyter_nbextensions_configurator\n!jupyter contrib nbextension install --user\n!jupyter nbextensions_configurator enable --user\n<\/code><\/pre>\n\n\n\n<p>Once installed, you can access the nbextensions tab from the Jupyter Notebook home screen. From there, you can browse available extensions and enable them with a single click.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/nbextensions.png\" alt=\"nbextensions\"\/><\/figure>\n\n\n\n<p><em>The nbextensions configurator interface.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">23. Create a Presentation from a Jupyter Notebook<\/h2>\n\n\n\n<p>Have you ever wanted to present your Jupyter Notebook as an interactive slideshow without exporting it to another tool? With the <a href=\"https:\/\/rise.readthedocs.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">RISE extension<\/a>, you can do just that\u2014directly within the notebook interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing RISE<\/h3>\n\n\n\n<p>You can install RISE using either <code>conda<\/code> or <code>pip<\/code>, depending on your preferred package manager:<\/p>\n\n\n\n<p><strong>Using Conda:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conda install -c conda-forge rise\n<\/code><\/pre>\n\n\n\n<p><strong>Using Pip:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install rise\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Enabling the Extension<\/h3>\n\n\n\n<p>Once installed, enable RISE with the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>jupyter-nbextension install rise --py --sys-prefix\njupyter-nbextension enable rise --py --sys-prefix\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Starting Your Presentation<\/h3>\n\n\n\n<p>After enabling RISE, open your notebook and click the &#8220;Enter\/Exit RISE Slideshow&#8221; button in the toolbar. You can navigate the slides using the arrow keys.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Customizing Slide Types<\/h3>\n\n\n\n<p>RISE allows you to control the flow of your presentation by specifying different slide types. Here are some helpful shortcuts for setting slide types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Shift + M<\/code>: Regular slide (Markdown cell)<\/li>\n\n\n\n<li><code>Shift + J<\/code>: Regular slide (Code cell)<\/li>\n\n\n\n<li><code>Shift + F<\/code>: Fragment slide (Markdown cell)<\/li>\n\n\n\n<li><code>Shift + H<\/code>: Sub-slide (Markdown cell)<\/li>\n\n\n\n<li><code>Shift + N<\/code>: Skip slide (Markdown cell)<\/li>\n<\/ul>\n\n\n\n<p>With RISE, you can turn your data exploration and analysis into engaging presentations directly from your Jupyter Notebook, making it easy to share insights interactively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">24. The Jupyter Output System<\/h2>\n\n\n\n<p>Jupyter Notebooks are displayed as HTML, and their cell outputs can also be HTML. This means you can return almost any type of media, including text, images, audio, and video, directly in your notebook cells.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Displaying Images from a Folder<\/h3>\n\n\n\n<p>In this example, we scan a folder containing images and display thumbnails of the first five:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nfrom IPython.display import display, Image \n\n# List PNG files in the specified directory\nnames = &#91;f for f in os.listdir('..\/images\/ml_demonstrations\/') if f.endswith('.png')]\n\n# Display the first five images as thumbnails\nfor name in names&#91;:5]:\n    display(Image('..\/images\/ml_demonstrations\/' + name, width=100))\n<\/code><\/pre>\n\n\n\n<p>The output displays thumbnails of the images:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/img1.png\" alt=\"img1\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/img2.png\" alt=\"img2\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/img3.png\" alt=\"img3\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/img4.png\" alt=\"img4\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dataquest.io\/wp-content\/uploads\/2019\/01\/img5.png\" alt=\"img5\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Generating the Same List Using Shell Commands<\/h3>\n\n\n\n<p>You can achieve the same result using a Bash command within a notebook cell. Jupyter magic commands allow shell outputs to be captured as Python variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Get a list of PNG files using a shell command\nnames = !ls ..\/images\/ml_demonstrations\/*.png \n\n# Display the first five filenames\nnames&#91;:5]\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n'..\/images\/ml_demonstrations\/colah_embeddings.png',\n'..\/images\/ml_demonstrations\/convnetjs.png',\n'..\/images\/ml_demonstrations\/decision_tree.png',\n'..\/images\/ml_demonstrations\/decision_tree_in_course.png',\n'..\/images\/ml_demonstrations\/dream_mnist.png'\n]\n<\/code><\/pre>\n\n\n\n<p>The Jupyter output system\u2019s flexibility allows you to explore, visualize, and manage data seamlessly by combining Python and shell commands in one environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">25. Enhance Interactivity with <code>ipywidgets<\/code><\/h2>\n\n\n\n<p><code>ipywidgets<\/code> is a powerful library that brings interactivity to your Jupyter notebooks. With widgets like sliders, buttons, checkboxes, and dropdowns, you can manipulate data in real-time, making your notebooks more dynamic and engaging.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installation<\/h3>\n\n\n\n<p>To get started, make sure <code>ipywidgets<\/code> is installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install ipywidgets\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Creating and Displaying Widgets<\/h3>\n\n\n\n<p>Import <code>ipywidgets<\/code> and the <code>display<\/code> function from <code>IPython.display<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ipywidgets as widgets\nfrom IPython.display import display\n<\/code><\/pre>\n\n\n\n<p>Let\u2019s create a simple slider widget:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>slider = widgets.FloatSlider(\n    value=5.0,\n    min=0.0,\n    max=10.0,\n    step=0.1,\n    description='Value:'\n)\ndisplay(slider)\n<\/code><\/pre>\n\n\n\n<p>This slider has a default value of 5.0, a range from 0.0 to 10.0, and a step size of 0.1. The <code>description<\/code> parameter adds a label to the slider.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Accessing Widget Values<\/h3>\n\n\n\n<p>To access the current value of the slider, use its <code>value<\/code> attribute:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(slider.value)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Interactive Button Example<\/h3>\n\n\n\n<p>ipywidgets also lets you create interactive buttons that trigger events. Let\u2019s build a button that prints a message when clicked:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>button = widgets.Button(description='Click me!')\noutput = widgets.Output()\n\ndef on_button_clicked(b):\n    with output:\n        print(\"Hello, Jupyter!\")\n\nbutton.on_click(on_button_clicked)\ndisplay(button, output)\n<\/code><\/pre>\n\n\n\n<p>When you click the button, the message <code>\"Hello, Jupyter!\"<\/code> will be printed inside the output widget.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Explore More Widgets<\/h3>\n\n\n\n<p>In addition to sliders and buttons, <code>ipywidgets<\/code> offers many other widgets like checkboxes, dropdowns, and text boxes. By using these widgets, you can transform your notebooks into interactive dashboards or teaching tools, enhancing the learning and exploratory experience.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">26. Big Data Analysis<\/h2>\n\n\n\n<p>Jupyter Notebooks offer several options for querying and processing large datasets, making it easier to work with big data directly from within your notebook environment. Here are some popular solutions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/dask.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dask<\/a>: A powerful library for parallel and distributed computing in Python, Dask scales your computations from a single machine to a large cluster without needing to change much code. It integrates seamlessly with pandas, NumPy, and other libraries.<\/li>\n\n\n\n<li><a href=\"https:\/\/pytorch.org\/docs\/stable\/ray.html\" target=\"_blank\" rel=\"noreferrer noopener\">Ray<\/a>: Designed for scalable, distributed applications, Ray is ideal for parallel model training, hyperparameter tuning, and general distributed workloads.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.dataquest.io\/blog\/install-and-learn-apache-spark-with-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">PySpark<\/a>: Integrates the power of Apache Spark with the simplicity of Python, enabling distributed data processing and analysis on large datasets.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/jupyter-incubator\/sparkmagic\" target=\"_blank\" rel=\"noreferrer noopener\">spark-sql magic<\/a>: This enables SQL queries directly within your notebook using <code>%%sql<\/code>, providing an interactive way to query large datasets. Alternatively, you can explore newer options like <a href=\"https:\/\/dask-sql.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dask SQL<\/a> or <a href=\"https:\/\/www.dataquest.io\/blog\/introduction-to-databricks-in-azure\/\" target=\"_blank\" rel=\"noreferrer noopener\">Databricks notebooks<\/a>.<\/li>\n<\/ul>\n\n\n\n<p>With these options, Jupyter Notebooks give you the flexibility to process and analyze large-scale data efficiently, making them a valuable tool for big data projects in data science and engineering.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">27. Set an Alarm for Code Completion<\/h2>\n\n\n\n<p>Adding just a few lines of code can enable Python to play a sound or even speak to you when your code execution is complete. This provides a convenient way to stay informed about long-running tasks without constantly monitoring the notebook.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For Windows Users:<\/h3>\n\n\n\n<p>Use the built-in <code>winsound<\/code> module to create a simple beep:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import winsound\n\nduration = 1000  # milliseconds\nfreq = 440  # Hz\nwinsound.Beep(freq, duration)\n<\/code><\/pre>\n\n\n\n<p>This code snippet will play a beep sound at a frequency of 440 Hz for 1 second when your code has finished running.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For Mac Users:<\/h3>\n\n\n\n<p>Use the built-in <code>say<\/code> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\n\nos.system('say \"Your program has finished\"')\n<\/code><\/pre>\n\n\n\n<p>This will make your Mac speak the phrase &#8220;Your program has finished&#8221; once the code execution is complete. You can customize the voice using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>os.system('say -v Alex \"Your program has finished\"')\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">For Linux Users:<\/h3>\n\n\n\n<p>First, install the <code>sox<\/code> package if it\u2019s not already installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install sox\n<\/code><\/pre>\n\n\n\n<p>Then, use this command to play a beep sound:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\n\nos.system('play -nq -t alsa synth 1 sine 440')\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Cross-Platform Option:<\/h3>\n\n\n\n<p>To ensure compatibility across Windows, Mac, and Linux, you can use the <code>playsound<\/code> library to play audio files. First, install it using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install playsound\n<\/code><\/pre>\n\n\n\n<p>Then, use the following code to play a sound file of your choice:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from playsound import playsound\n\nplaysound('path\/to\/sound.mp3')\n<\/code><\/pre>\n\n\n\n<p>This flexible approach lets you play custom audio notifications regardless of your operating system.<\/p>\n\n\n\n<p>By adding simple audio notifications, you can stay informed about long-running tasks without needing to constantly check your Jupyter Notebook.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">28. Sharing Jupyter Notebooks<\/h2>\n\n\n\n<p>The easiest way to share your notebook is by sharing the notebook file (<code>.ipynb<\/code>) directly. However, if the recipient doesn\u2019t have Jupyter installed, you can use one of these options:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Convert to HTML:<\/strong> Use the <code>File > Download as > HTML<\/code> option to convert and share an HTML version of your notebook, which can be viewed in any browser.<\/li>\n\n\n\n<li><strong>Upload to Google Colab:<\/strong> Upload your <code>.ipynb<\/code> file to <a href=\"https:\/\/colab.research.google.com\/notebooks\/intro.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">Google Colab<\/a>, a free online environment for running notebooks without local installation.<\/li>\n\n\n\n<li><strong>Share via GitHub or Gists:<\/strong> Upload your notebook to <a href=\"https:\/\/gist.github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gists<\/a> or GitHub, which both natively render notebooks. See <a href=\"https:\/\/github.com\/dataquestio\/solutions\/blob\/master\/Lesson202Solution.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">this example<\/a> as a reference.\n<ul class=\"wp-block-list\">\n<li><strong>Bonus:<\/strong> Use <a href=\"https:\/\/mybinder.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">mybinder<\/a> to provide up to 30 minutes of interactive Jupyter access directly from a GitHub repository.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set up a multi-user environment with JupyterHub:<\/strong> For workshops or courses, consider <a href=\"https:\/\/github.com\/jupyterhub\/jupyterhub\" target=\"_blank\" rel=\"noreferrer noopener\">JupyterHub<\/a>. This setup allows multiple users to access notebooks without needing local installations.<\/li>\n\n\n\n<li><strong>Host with Dropbox and render with nbviewer:<\/strong> Store your notebook on Dropbox or a similar file-sharing service and generate a shareable link. Then, use <a href=\"https:\/\/nbviewer.jupyter.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">nbviewer<\/a> to render and view the notebook directly from the link.<\/li>\n\n\n\n<li><strong>Export as PDF:<\/strong> Use <code>File > Download as > PDF<\/code> to create a PDF version. For tips on creating polished, publication-ready notebooks, check out <a href=\"https:\/\/blog.juliusschulz.de\/blog\/ultimate-ipython-notebook\" target=\"_blank\" rel=\"noreferrer noopener\">Julius Schulz\u2019s guide<\/a>.<\/li>\n\n\n\n<li><strong>Create a blog post using Pelican:<\/strong> Convert notebooks into blog posts with <a href=\"https:\/\/www.dataquest.io\/blog\/how-to-setup-a-data-science-blog\/\" target=\"_blank\" rel=\"noreferrer noopener\">Pelican<\/a>, a static site generator for Python-based blogs.<\/li>\n<\/ul>\n\n\n\n<p><strong>Tip:<\/strong> Choose your sharing method based on your audience\u2014HTML files and <a href=\"https:\/\/www.dataquest.io\/blog\/getting-started-with-google-colab-for-deep-learning\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google Colab<\/a> links are great for non-technical users, while GitHub repositories and JupyterHub setups are ideal for technical collaborators.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Next Steps<\/h2>\n\n\n\n<p>I hope you&#8217;ve enjoyed my favorite Jupyter Notebook tips and tricks. If you want to go even deeper, here are some additional resources I recommend to further enhance your understanding of Jupyter Notebook:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/ipython.readthedocs.io\/en\/stable\/interactive\/magics.html\" target=\"_blank\" rel=\"noreferrer noopener\">IPython Magic Commands Documentation<\/a> \u2013 Learn how to use powerful magic commands to streamline your workflow.<\/li>\n\n\n\n<li><a href=\"https:\/\/ipywidgets.readthedocs.io\/en\/stable\/\" target=\"_blank\" rel=\"noreferrer noopener\">ipywidgets Documentation<\/a> \u2013 Build interactive widgets to enhance notebook interactivity.<\/li>\n\n\n\n<li><a href=\"https:\/\/realpython.com\/python-timer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Profiling and Timing Python Code<\/a> \u2013 Learn how to time and optimize your Python code effectively.<\/li>\n\n\n\n<li><a href=\"https:\/\/mybinder.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">MyBinder<\/a> \u2013 Share and run Jupyter notebooks online without local setup.<\/li>\n\n\n\n<li><a href=\"https:\/\/mindtrove.info\/4-ways-to-extend-jupyter-notebook\/\" target=\"_blank\" rel=\"noreferrer noopener\">4 Ways to Extend Jupyter Notebooks<\/a> \u2013 Learn how to customize and extend notebooks to meet advanced needs.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Jupyter Notebook is a must-have tool for anyone working with data, allowing you to write and run live code, display visuals, and mix in narrative text\u2014all in one interactive document. In this post, I\u2019ll share my favorite Jupyter Notebook tips, tricks, and shortcuts to help you work smarter and more efficiently. If you\u2019re just getting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"wp-custom-template-pagina-personale-membro","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1162","post","type-post","status-publish","format-standard","hentry","category-senza-categoria"],"_links":{"self":[{"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/posts\/1162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/comments?post=1162"}],"version-history":[{"count":1,"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/posts\/1162\/revisions"}],"predecessor-version":[{"id":1163,"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/posts\/1162\/revisions\/1163"}],"wp:attachment":[{"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/media?parent=1162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/categories?post=1162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.cs.infn.it\/wordpress\/wp-json\/wp\/v2\/tags?post=1162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}