Full width home advertisement

Post Page Advertisement [Top]

Jupyter Notebook Tricks

Shortcuts

Get multiple cursors by pressing ctrl and clicking on the required places Just like you select different files with ctrl key.



# list available python magics
%lsmagic

# print all string variables
%who str

# Suppress output of last line
a="This is the Output -_- "
a;

# See the source of anything with ? and ??
a?
round??
pip?
%pip?
%pip??

# can execute python code from .py and .ipynb files
%run 
# usage
%run ./hello.ipynb

# Load any file,code also images in binary form
%load ./hello.ipynb

# Timing, measure time spent 
%%time
import time
print("Hi"*10)

# see timing by each functions lprun and mprun is broker in many not working in many 
%prun, %lprun, %mprun

%prun
import time
def red():
    time.sleep(1)
    print("I'm Red")
    
def green():
    time.sleep(0.5)
    print("I'm Green")    
    
    
def speed():
    red()
    green()

speed()


#Convert your Notebook to Prompt less Notebook
%%bash
jupyter nbconvert --to blogger_html /home/abhishek/Desktop/GLR2020/GLR2020_home.ipynb --no-prompt

%%bash
echo "hellow from $BASH"

from IPython.display import Image
Image(filename='fig/img_4926.jpg')

%load_ext sympyprinting
import sympy as sym
from sympy import *
x, y, z = sym.symbols("x y z")

eq = ((x+y)**3 * (x+4+z))
eq
(𝑥+𝑦)3(𝑥+𝑧+4)

expand(eq)
𝑥4+3𝑥3𝑦+𝑥3𝑧+4𝑥3+3𝑥2𝑦2+3𝑥2𝑦𝑧+12𝑥2𝑦+𝑥𝑦3+3𝑥𝑦2𝑧+12𝑥𝑦2+𝑦3𝑧+4

from IPython.display import YouTubeVideo
YouTubeVideo('iwVvqwLDsJo')

















No comments:

Post a Comment

Labels

python (3) jupyter (2) jupyter notebook (2) Cheatsheet (1) Git (1) Github (1) Tricks (1) data science (1) linux (1) machine learning (1) ml (1) pip (1) pip3 (1) py (1) python3 (1)

Bottom Ad [Post Page]