In [2]:
%matplotlib inline
%config InlineBackend.figure_format='retina'
In [3]:
# Add this to python2 code to make life easier
from __future__ import absolute_import, division, print_function
In [4]:
from itertools import combinations
import string
from IPython.display import IFrame, HTML, YouTubeVideo
import matplotlib as mpl
from matplotlib import pyplot as plt
from matplotlib.pyplot import GridSpec
import seaborn as sns
import numpy as np
# don't do:
# from numpy import *
In [5]:
import pandas as pd
import os, sys
import warnings
sns.set();
plt.rcParams['figure.figsize'] = (12, 8)
sns.set_style("darkgrid")
sns.set_context("poster", font_scale=1.3)
warnings.filterwarnings('ignore')
In [17]:
# in select mode, shift j/k (to select multiple cells at once)
# split cell with ctrl shift -
# merge with shift M
In [18]:
first = 1
In [19]:
second = 2
In [21]:
third = 3
You can also get monospaced fonts by indenting 4 spaces:
mkdir toc
cd toc
Wrap with triple-backticks and language:
mkdir toc
cd toc
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
In [22]:
import numpy as np
In [ ]:
np.random.choice()
SELECT first_name,
last_name,
year_of_birth
FROM presidents
WHERE year_of_birth > 1800;
In [24]:
mylist = !ls
In [27]:
[x.split('_')[-1] for x in mylist]
Out[27]:
In [29]:
%%bash
pwd
for i in *.ipynb
do
echo $i | awk -F . '{print $1}'
done
echo
echo "break"
echo
for i in *.ipynb
do
echo $i | awk -F - '{print $2}'
done
In [10]:
def silly_function(xval):
"""Takes a value and returns the absolute value."""
xval_sq = xval ** 2.0
1 + 4
xval_abs = np.sqrt(xval_sq)
return xval_abs
In [11]:
silly_function?
In [12]:
silly_function??
In [ ]:
silly_function()
In [ ]:
import numpy as np
In [9]:
#
np.linspace??
In [8]:
#
np.linspace?
In [40]:
ex_dict = {}
In [41]:
# Indent/dedent/comment
for _ in range(5):
ex_dict["one"] = 1
ex_dict["two"] = 2
ex_dict["three"] = 3
ex_dict["four"] = 4
In [42]:
ex_dict
Out[42]:
In [44]:
ex_dict["one_better_name"] = 1.
ex_dict["two_better_name"] = 2.
ex_dict["three_better_name"] = 3.
ex_dict["four_better_name"] = 4.
In [ ]: