Jupyter Notebook Magic Commands

Do You Believe in Magic? Python Programmers do: Magic Commands

Explore the Top Jupyter Notebook Magic Commands and Boost Your Data Productivity 10x

Tomas Šostak
Jun 1, 2020 · 4 min read

1. Benchmarking

numpy.ndarray vs pandas.DataFrame row-wise iteration speed comparison (note that NumPy way is ~100x faster!). df.mean uses NumPy functionality under the hood thus similar performance as np.mean

2. HTML snippets

%%html
<img src="https://bit.ly/3djzw7h" alt="fiiire ball" />

3. System interactions

%system date
# Output: ['Sun 31 May 2020 15:40:38 BST']
!date
# Output: Sat 18 Apr 2020 14:35:53 BST
!ls
# Output: all files and folders in your current directory
!pip install numpy

4. Write to a file/read a file

5. WHO

number = 42
string = "hello world"
%who
# Output:
# number string
%who int
# Output:
# number
%whos
# Output:
# Variable Type Data/Info
# ----------------------------
# number int 42
# string str hello world

6. Share variables between notebooks

your_data = 'your object'
%store your_data
del your_data
%store -r your_data
your_data

Worth mentioning

The Startup

Get smarter at building your thing. Join The Startup’s +788K followers.

Sign up for Top 10 Stories

By The Startup

Get smarter at building your thing. Subscribe to receive The Startup's top 10 most read stories — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Tomas Šostak

Written by

- it’s all about the data -

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +788K followers.

Tomas Šostak

Written by

- it’s all about the data -

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +788K followers.