In [1]:
import numpy as np

In [7]:
t = 24
alpha = 0.05
1.7 * np.sqrt((np.log(np.log(2 * t)) + 0.72 * np.log(5.2 / alpha)) / t)


Out[7]:
0.752104016744892

In [3]:
t = 14
1.7 * np.sqrt(t * (np.log10(np.log10(2 * t))))


Out[3]:
2.5484261237266748

In [ ]:


In [2]:
# Add this to python2 code to make life easier -- safe to use in python3 as well.
from __future__ import absolute_import, division, print_function

In [3]:
import numpy as np
# don't do:
# from numpy import *

In [4]:
max('a')

In [5]:
np.max('a')

In [6]:
%matplotlib inline
%config InlineBackend.figure_format='retina'

In [7]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os
from pivottablejs import pivot_ui
import sys
import warnings
warnings.filterwarnings('ignore')

In [8]:
first = 1

In [9]:
second = 2

In [10]:
third = 3

In [11]:
# df = pd.read_csv("../data/mps.csv", encoding="ISO-8859-1")
# canadian_politics = pd.read_csv("../data/montreal_2014.csv",)
canadian_politics = pd.read_csv("../data/mps2.csv",)

In [12]:
# recommend using .head()
canadian_politics.head(10)

In [13]:
sns.distplot(canadian_politics['Age'].dropna())

In [14]:
sns.distplot(canadian_politics['Age'])

In [15]:
sns.distplot(canadian_politics['Age'].dropna())

In [16]:
sns.set_context('poster', font_scale=1.3)

In [17]:
fig, ax = plt.subplots(figsize=(12, 8))
sns.distplot(canadian_politics['Age'].dropna())
fig.tight_layout()

In [18]:
sns.distplot(canadian_politics['Age'].dropna());

In [19]:
pivot_ui(canadian_politics)

In [20]:
import numpy as np

In [21]:
np.linspace?

In [22]:
np.linspace??

In [23]:
np.linspace??

In [24]:
!subl ~/miniconda3/envs/dspy3/lib/python3.6/site-packages/numpy/core/function_base.py

In [25]:
import textwrap
def example_function():
    """Docstring for example function"""
    
    print(textwrap.dedent("""
    This is a multi-lined string
    that I want to write inside of a function.
    Notice what happens when I print this.
        And when something is indented more."""))


example_function()

In [26]:
# But first find and replace
def silly_function(xval):
    """Takes a value and returns the value."""
    xval_sq = xval ** 2.0
    1 + 10
    xval_abs = np.sqrt(xval_sq)
    return xval_abs

In [27]:
silly_function(2,)

In [28]:
silly_function(-2,)

In [29]:
silly_function?

In [30]:
silly_function??

In [31]:
# But first find and replace
def silly_function(xval):
    """Takes a value and returns the value."""
    xval_sq = xval ** 2.0
    1 + 12
    xval_abs = np.sqrt(xval_sq)
    return xval_abs

In [32]:
silly_function??

In [33]:
!ls ../data/

In [34]:
coal_years = !ls ../data/coal_prod_20*.csv

In [35]:
coal_years

In [36]:
example_dict = {}

# Indent/dedent/comment
for index in range(5):
    example_dict["float_one"] = 1.0
    example_dict["float_two"] = 2.0
    example_dict["float_three"] = 3.0
    example_dict["float_four"] = 4.0

In [37]:
example["one_better_neat"] = 1
example["two_better_neat"] = 2
example["three_better_neat"] = 3
example["four_better_neat"] = 4

In [38]:
example_ = {}

# Indent/dedent/comment
for index in range(5):
    example_["float_one"] = 1.0
    example_["float_two"] = 2.0
    example_["float_three"] = 3.0
    example_["float_four"] = 4.0

In [39]:
example["one_better_neat"] = 1
example["two_better_neat"] = 2
example["three_better_neat"] = 3
example["four_better_neat"] = 4

In [40]:
example = {}

# Indent/dedent/comment
for index in range(5):
    example["float_one"] = 1.0
    example["float_two"] = 2.0
    example["float_three"] = 3.0
    example["float_four"] = 4.0

In [41]:
example["one_better_neat"] = 1
example["two_better_neat"] = 2
example["three_better_neat"] = 3
example["four_better_neat"] = 4

In [42]:
%%latex

If you want to get crazier$\ldots$

\begin{equation}
\oint_S {E_n dA = \frac{1}{{\varepsilon _0 }}} Q_\textrm{inside}
\end{equation}

In [43]:
%%python2
print "hi"

In [44]:
%%bash
wget http://www.ast.cam.ac.uk/~rfc/vpfit11.1.tar.gz
mkdir -p vpfit11
cd vpfit11
tar -xvzf ../vpfit11.1.tar.gz

In [45]:
normal_argument = 12.4
second_argument = 98.4

arg_with_spaces = "the secret to life"

In [46]:
%%bash -s {normal_argument} {second_argument}
echo "This script knows the value of the argument: $1"
echo "It also has no trouble with the second argument: $2"

In [47]:
%%bash -s "$arg_with_spaces"
echo "This bash script knows $1."

In [48]:
ls

In [49]:
!ls

In [50]:
%ls

In [51]:
ls vpfit10/

In [52]:
tailthing = "*.ipynb"

In [53]:
tailthing

In [54]:
!ls {tailthing}

In [55]:
output = !ls

In [56]:
output

In [57]:
!pwd

In [58]:
a = 3
a

In [59]:
_58

In [60]:
_i58