Hi Reader,
If you spend a lot of time in Jupyter Notebook, the easiest way to increase your productivity is by using the built-in keyboard shortcuts.
Unlike most applications, Jupyter's keyboard shortcuts are easy to remember since they often only require a single key.
Below, I'll cover the most useful keyboard shortcuts (including some hidden gems ๐) so that you can speed up your workflow today!
I'm focusing on Jupyter Notebook in this email, but I've made a note of any differences for JupyterLab.
Before we begin, it's critical that you're aware of the difference between Command Mode and Edit Mode, since different shortcuts work for each mode.
In Edit Mode, there's a blinking cursor and a green border, whereas in Command Mode, there's a gray border with a blue bar:
To change modes:
Note: JupyterLab uses a blue border for Edit Mode.
Here are the keyboard shortcuts you should learn first, because you'll use these the most:
Command Mode:
You can use dd (meaning "d" twice) to delete cells, but I just use x instead.
Edit Mode:
Either Mode:
These shortcuts are not as well-known, but will help you to become a true power user:
Command Mode:
p: Open the command palette. You can scroll or search through commands, then select an action and hit Enter to run it.
JupyterLab: Cmd+Shift+c (Mac), Ctrl+Shift+c (Windows)
o: Toggle between hiding and showing the output for selected code cells. This is useful when the output is taking up too much of your screen.
JupyterLab: This shortcut is not available. Instead, open the command palette and search for "Collapse Selected Outputs."
z: Undo cell deletion. You can undo multiple deletions, and each cell will go back to its original position. It works even if you have done other work since the deletions!
Edit Mode:
Cmd+/ (Mac), Ctrl+/ (Windows): Toggle between commented and uncommented code. You can apply this to multiple lines at once by first selecting those lines.
Shift+Tab: View the docstring for a function. Hit Shift+Tab three more times to open the docstring in a new pane.
JupyterLab: Hit Shift+Tab once.
Multi-cursor support: Hold down Option (Mac) or Alt (Windows), then click your mouse and drag up or down. This allows you to edit multiple lines at once.
How helpful was todayโs tip?
If you enjoyed this issue, please forward it to a friend! Takes only a few seconds, and it really helps me out ๐
See you next Tuesday!
- Kevin
P.S. Did someone awesome forward you this email? Sign up here to receive data science tips every week!
Join 25,000+ intelligent readers and receive AI tips every Tuesday!
Hi Reader, Last week, I encouraged you to experiment with different LLMs, since thereโs no one model that is superior across all use cases. Specifically, I suggested you try using Chatbot Arena, which allows you to chat with multiple models at once. Itโs completely free, but has two significant disadvantages: Your chats are not private and may be used for research. It lacks the feature-rich interface provided by other LLMs. Today, I want to offer you a better method for experimenting with...
Hi Reader, Over the past 50 tips, Iโve touched on many different topics: Python, Jupyter, pandas, ML, data visualization, and so on. Going forward, Iโm planning to focus mostly on Artificial Intelligence. Iโm announcing this so you know what to expect, and I know what to deliver! ๐ Iโll also try to make the tips shorter, so that they're easier to digest on-the-go. Finally, I plan to include an โaction itemโ each week, so that you can practice what youโre learning. I hope you like these...
Hi Reader, Next week, Iโll be offering a Black Friday sale on ALL of my courses. Iโll send you the details this Thursday! ๐จ ๐ Tip #50: What is a "method" in Python? In Python, a method is a function that can be used on an object because of the object's type. For example, if you create a Python list, the "append" method can be used on that list. All lists have an "append" method simply because they are lists: If you create a Python string, the "upper" method can be used on that string simply...