cd ~
# 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
print("Datestamp:")
print(time.strftime(r'%Y-%m-%dT%H:%M:%S%Z', time.gmtime()))
print()
print("Python version:")
print(sys.version_info)
# File paths
path_static = os.path.join(os.path.expanduser(r'~'), r'stharrold.github.io/content/static')
basename = r'20151030-test'
filename = basename
Description of section 1.
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
plt.plot([0,1], [0,1])
path_jpg = os.path.join(path_static, basename, r'plot.jpg')
plt.savefig(path_jpg)
print(path_jpg)
# 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()