Skip to main content

nbtof: transfering notebook to function

Project description

nbtof

This module is used to transfer .ipynb file to .py function. Table of contents

Intoroduction

Jupyter notebookに#@タグをつけることで, notebookの一連の処理を関数に変換することができます.
たとえば, 下記short_sample.ipynbの処理を関数化する場合,

short_sample.ipynb

#@param
a = 1
b = 1
c = a + b
#@return
c

以下を実行すると, 関数化されたoutput.pyが出力されます.

import nbtof

nbtof.nbtof_generate(
    output_py_file='output.py',
    notebook_file='short_sample.ipynb',
    )

output.py

def short_sample(a, b):
    c = a + b
    return c

Documantation

Tags

Tag Description
#@param 関数の引数になります. 代入した数値は無視されます.
#@default 関数の引数になります. 代入した数値が既定値として設定されます.
#@args 関数の可変長引数 *args になります. 代入した数値は無視されます.
#@kwargs 関数の可変長引数 **kwargs になります. 代入した数値は無視されます.
#@return 関数の戻り値になります.
#@ignore セル内の内容は無視されます.
#@help 関数内の docstring になります.

Examples and Recomended Usage

Setting Parameters

Batch processing

複数のnotebook, 関数をまとめて1つの py fileに出力する場合は引数のnotebook_fileにnotebookのfilenameもしくはfilepathをリストにして渡す.

Installation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbtof-0.0.2.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file nbtof-0.0.2.tar.gz.

File metadata

  • Download URL: nbtof-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for nbtof-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5a98de7e98a092c1bdf3b2c29904e96b953431675fb7eafb01a7e0ae255b427d
MD5 41c1346af81d608ab050602513186707
BLAKE2b-256 99750792d95300a015d8f31653abae354143cc6ac100e756bc7d81ef4badb91e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page