You can execute Shell commands with the prefix !
In [36]:
!ls -la
!pwd
In [37]:
!pip install numpy
!pip list | grep pandas
In [9]:
%lsmagic
Out[9]:
%alias
%alias_magic
%autocall
%automagic
%autosave
%bookmark
%cat
%cd
%clear
%colors
%config
%connect_info
%cp
%debug
%dhist
%dirs
%doctest_mode
%ed
%edit
%env # %env: Set Environment Variables
%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
%popd
%pprint
%precision
%profile
%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 # time code execution
%timeit # time code execution
%unalias
%unload_ext
%who
%who_ls
%whos
%xdel
%xmode
In [16]:
# lists all environment variables
%env
# Set environment variable NUM_THREADS
%env NUM_THREADS=4
In [25]:
# %run: Execute python code
# Run another nothebook entirely
%run ../sample_files/hello_world.ipynb
In [26]:
# loads content of a file into the cell
# %load ../sample_files/hello_world.py
if __name__ == "__main__":
print("Hello World!")
In [31]:
# %time will give you information about a single run of the code in your cell.
%time
import time
for _ in range(1000):
time.sleep(0.01)# sleep for 0.01 seconds
In [29]:
# %timeit uses the Python timeit module which runs a statement 100,000 times (by default) and then provides the mean of the fastest three times.
import numpy
%timeit numpy.random.normal(size=100)
In [35]:
%matplotlib inline
import matplotlib.pyplot as plt
x = range(1000)
y = [i ** 2 for i in x]
plt.plot(x,y)
plt.show();
%config InlineBackend.figure_format = 'retina'
plt.plot(x,y)
plt.show();
In [ ]:
%%!
%%HTML
%%SVG
%%bash
%%capture
%%debug
%%file
%%html
%%javascript
%%js
%%latex
%%perl
%%prun
%%pypy
%%python
%%python2
%%python3
%%ruby
%%script
%%sh
%%svg
%%sx
%%system
%%time
%%timeit
%%writefile
In [4]:
from IPython.display import Image
Image(filename='../sample_files/xkcd_estimation.png')
Out[4]:
In [41]:
from IPython.display import Image
Image(url='http://python.org/images/python-logo.gif')
Out[41]:
In [43]:
from IPython.display import YouTubeVideo
YouTubeVideo('1j_HxD4iLn8')
Out[43]:
In [47]:
import antigravity