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.1.tar.gz (8.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: nbtof-0.0.1.tar.gz
  • Upload date:
  • Size: 8.5 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.1.tar.gz
Algorithm Hash digest
SHA256 44c594de990e47ab4c3c8d966f69197e9d977129d9e4234512f5c9ce40eee019
MD5 5526887cf1b249e73621362b2af38f91
BLAKE2b-256 5a0400b2e4d2c630b7b83ad9981c4964b04594cc1044acace5b69570206e8b7c

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