goude/jupyter-virtualenv examples

See https://nbviewer.jupyter.org/github/ipython/ipython/blob/2.x/examples/Notebook/Index.ipynb

how to run this notebook

It's dead simple. First, install docker. Next, type the command below in a terminal and press enter.

docker run goude/jupyter-virtualenv start-jupyter.sh

Finally, point your browser to http://localhost:8888.

setup


In [1]:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import os

pyfiglet


In [2]:
import pyfiglet
f = pyfiglet.Figlet()
print(f.renderText('Hello, World!'))


 _   _      _ _         __        __         _     _ _ 
| | | | ___| | | ___    \ \      / /__  _ __| | __| | |
| |_| |/ _ \ | |/ _ \    \ \ /\ / / _ \| '__| |/ _` | |
|  _  |  __/ | | (_) |    \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___( )    \_/\_/ \___/|_|  |_|\__,_(_)
                    |/                                 


In [3]:
from wordcloud import WordCloud, STOPWORDS

wordlist = !pip freeze
wordcloud = WordCloud(stopwords=STOPWORDS, background_color='white').generate(" ".join(wordlist))
plt.figure(figsize=(15,10))
plt.figure()
plt.imshow(wordcloud)
plt.axis('off')
plt.show()


<matplotlib.figure.Figure at 0x1071ce898>

In [4]:
from IPython.display import Math
Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')


Out[4]:
$$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$

In [5]:
%%latex
\begin{align}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}


\begin{align} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align}

In [6]:
#from matplotlib import pyplot as plt
from matplotlib_venn import venn2, venn2_circles

# Subset sizes
s = (
    2,  # Ab
    3,  # aB
    1,  # AB
)

v = venn2(subsets=s, set_labels=('A', 'B'))

# Subset labels
v.get_label_by_id('10').set_text('A but not B')
v.get_label_by_id('01').set_text('B but not A')
v.get_label_by_id('11').set_text('A and B')

# Subset colors
#v.get_patch_by_id('10').set_color('c')
#v.get_patch_by_id('01').set_color('#993333')
#v.get_patch_by_id('11').set_color('blue')

# Subset alphas
#v.get_patch_by_id('10').set_alpha(0.4)
#v.get_patch_by_id('01').set_alpha(1.0)
#v.get_patch_by_id('11').set_alpha(0.7)

# Border styles
c = venn2_circles(subsets=s, linestyle='solid')
c[0].set_ls('dashed')  # Line style
c[0].set_lw(2.0)       # Line width

plt.show()



In [7]:
from IPython.display import IFrame
IFrame('http://m.wikipedia.org/?useformat=mobile', width='100%', height=350)


Out[7]:

In [8]:
from IPython.display import Audio
max_time = 3
f1 = 220.0
f2 = 224.0
rate = 8000
L = 3
times = np.linspace(0,L,rate*L)
signal = np.sin(2*np.pi*f1*times) + np.sin(2*np.pi*f2*times)

Audio(data=signal, rate=rate)


Out[8]:

In [9]:
import folium
folium.Map()


Out[9]:

In [10]:
import vincent
vincent.core.initialize_notebook()

from pandas_datareader import data as web
all_data = {}
for ticker in ['AAPL', 'GOOG', 'IBM', 'YHOO', 'MSFT']:
    all_data[ticker] = web.get_data_yahoo(ticker, '2010-01-01', '2016-05-01')
price = pd.DataFrame({tic: data['Adj Close']
                      for tic, data in all_data.items()})

line = vincent.Line(price[['GOOG', 'AAPL']])
line.axis_titles(x='Date', y='Price')
line.legend(title='GOOG vs AAPL')
line.display()