53
55

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jupyter notebook ใง HTML ใ‚‚่‡ชๅ‹•ไฝœๆˆ

53
Last updated at Posted at 2016-05-04

Jupyter notebook ใฏๅฟซ้ฉใ ใ‘ใ‚Œใฉใ‚‚ใ€ๆ˜”ใฎใƒŽใƒผใƒˆใƒ–ใƒƒใ‚ฏใ‚’่ฆ‹ใ‚‹ใŸใ‚ใซใ‚ตใƒผใƒใƒผใ‚’ใ‚ใ–ใ‚ใ–่ตทๅ‹•ใ•ใ›ใ‚‹ใฎใŒๆฐ—ๅˆ†็š„ใซ้ขๅ€’ใจใ„ใ†ใ“ใจใŒใ‚ใ‚‹ใ€‚ๅŒๅƒšใจๆƒ…ๅ ฑใ‚’ๅ…ฑๆœ‰ใ™ใ‚‹ใฎใซ HTML ใฎใปใ†ใŒ่‰ฏใ„ใจใ„ใ†ใ“ใจใ‚‚ใ‚ใ‚‹ใ‹ใ‚‚ใ—ใ‚Œใชใ„ใ€‚ใใ†ใ„ใ†ๆ™‚ใฎใŸใ‚ใซใ€่‡ชๅ‹•็š„ใซ HTML ใƒ•ใ‚กใ‚คใƒซใจ py ใƒ•ใ‚กใ‚คใƒซใ‚’ไฟๅญ˜ใ™ใ‚‹ใ‚ˆใ†ใซใ—ใฆใŠใใจไพฟๅˆฉใ€‚

ใพใšใ€๏ผˆใชใ‘ใ‚Œใฐ๏ผ‰่จญๅฎšใƒ•ใ‚กใ‚คใƒซใ‚’ไฝœใ‚‹ใ€‚

% jupyter notebook --generate-config

ไฝœใ‚‰ใ‚ŒใŸ ~/.jupyter/jupyter_notebook_config.py ใ‚’้–‹ใ„ใฆ

# -----------------------------
# Configurable configuration
# -----------------------------

ใฎไธ‹ใซใงใ‚‚

import os
from subprocess import check_call

def post_save(model, os_path, contents_manager):
    """post-save hook for converting notebooks to .py scripts"""
    if model['type'] != 'notebook':
        return # only do this for notebooks
    d, fname = os.path.split(os_path)
    check_call(['jupyter', 'nbconvert', '--to', 'script', fname], cwd=d)
    check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d)

c.FileContentsManager.post_save_hook = post_save

ใ“ใ‚Œใงใ€ipynb ใŒไฝœใ‚‰ใ‚Œใ‚‹ใจๅŒๆ™‚ใซๅŒๅใฎ html ใจ py (ใ‚ใ‚‹ใ„ใฏ r ใชใฉ๏ผ‰ใŒไฝœใ‚‰ใ‚Œใ‚‹ใ€‚

ๅ‚่€ƒ

Jupyter Notebook for Data Science Teams (O'Reilly)

ipython nbconvert ใฏๅคใ„ใจใ„ใ†่ญฆๅ‘ŠใŒใงใ‚‹ใฎใงใ€ๅ‚่€ƒๅ…ƒใฎใ‚ณใƒผใƒ‰ใฎ ipython ใ‚’ jupyter ใซๅค‰ๆ›ดใ—ใพใ—ใŸใ€‚

53
55
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
53
55

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?