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+ aspiring Data Scientists and receive Python & Data Science tips every Tuesday!
Hi Reader, Last week, I announced that a new course is coming soon and invited you to guess the topic. Hundreds of guesses were submitted, and four people who guessed correctly got the course for free! (I've already notified the winners.) I'll tell you about the course next week. In the meantime, I've got a new Tuesday Tip for you! π π Link of the week OpenAI just unleashed an alien of extraordinary ability (Understanding AI) If you're curious about what makes OpenAI's new "o1" models so...
Hi Reader, I'm really proud of this week's tip because it covers a topic (data leakage) that took me years to fully understand. π§ It's one of those times when I feel like I'm truly contributing to the collective wisdom by distilling complex ideas into an approachable format. π‘ You can read the tip below π or on my blog. π Link of the week Building an AI Coach to Help Tame My Monkey Mind (Eugene Yan) In this short post, Eugene describes his experiences calling an LLM on the phone for coaching:...
Hi Reader, Last week, I recorded the FINAL 28 LESSONS π for my upcoming course, Master Machine Learning with scikit-learn. That's why you didn't hear from me last week! π I edited one of those 28 videos and posted it on YouTube. That video is today's tip, which I'll tell you about below! π Tip #45: How to read the scikit-learn documentation In order to become truly proficient with scikit-learn, you need to be able to read the documentation. In this video lesson, Iβll walk you through the five...