20151030-test

Heading2

Heading3

Heading4

Heading5
Heading6

Description.

Initialization

Imports

In [1]:
cd ~
/home/samuel_harrold
In [2]:
# Import standard packages.
import os
import pdb # Debug with pdb.
import subprocess
import sys
import time
# Import installed packages.
import matplotlib.pyplot as plt
import pandas as pd
# Import local packages.
# Append current directory to module search path.
# Autoreload local packages after editing.
# `dsdemos` version: https://github.com/stharrold/dsdemos (master branch)
sys.path.insert(0, os.path.join(os.path.curdir, r'dsdemos'))
%reload_ext autoreload
%autoreload 2
import dsdemos as dsd
%matplotlib inline
In [3]:
print("Datestamp:")
print(time.strftime(r'%Y-%m-%dT%H:%M:%S%Z', time.gmtime()))
print()
print("Python version:")
print(sys.version_info)
Datestamp:
2016-01-04T16:44:26GMT

Python version:
sys.version_info(major=3, minor=5, micro=1, releaselevel='final', serial=0)

Globals

In [4]:
# File paths
path_static = os.path.join(os.path.expanduser(r'~'), r'stharrold.github.io/content/static')
basename = r'20151030-test'
filename = basename

Section 1

Description of section 1.

In [5]:
df = pd.DataFrame([['a', 'A', 10], ['b', 'B', 11], ['c', 'C', 12]], columns=['c0', 'c1', 'c2'])
path_html = os.path.join(path_static, basename, r'table.html')
df.to_html(buf=path_html)
print(path_html)
df
/home/samuel_harrold/stharrold.github.io/content/static/20151030-test/table.html
Out[5]:
c0 c1 c2
0 a A 10
1 b B 11
2 c C 12
In [6]:
plt.plot([0,1], [0,1])
path_jpg = os.path.join(path_static, basename, r'plot.jpg')
plt.savefig(path_jpg)
print(path_jpg)
/home/samuel_harrold/stharrold.github.io/content/static/20151030-test/plot.jpg

Export ipynb to html

In [7]:
# Export ipynb to html
path_ipynb = os.path.join(path_static, basename, filename+'.ipynb')
for template in ['basic', 'full']:
    path_html = os.path.splitext(path_ipynb)[0]+'-'+template+'.html'
    cmd = ['jupyter', 'nbconvert', '--to', 'html', '--template', template, path_ipynb, '--output', path_html]
    print(' '.join(cmd))
    subprocess.run(args=cmd, check=True)
    print()
jupyter nbconvert --to html --template basic /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test.ipynb --output /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test-basic.html

jupyter nbconvert --to html --template full /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test.ipynb --output /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test-full.html