Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/williamjameshandley/py2nb
convert python scripts to jupyter notebooks
https://github.com/williamjameshandley/py2nb
converter ipython jupyter-notebook python python-script
Last synced: 2 months ago
JSON representation
convert python scripts to jupyter notebooks
- Host: GitHub
- URL: https://github.com/williamjameshandley/py2nb
- Owner: williamjameshandley
- License: gpl-3.0
- Created: 2018-11-04T13:44:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T11:45:32.000Z (almost 2 years ago)
- Last Synced: 2024-09-28T18:40:56.362Z (3 months ago)
- Topics: converter, ipython, jupyter-notebook, python, python-script
- Language: Python
- Size: 80.1 KB
- Stars: 36
- Watchers: 6
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
==================================================
py2nb: convert python scripts to jupyter notebooks
==================================================
:py2nb: convert python scripts to jupyter notebooks
:Author: Will Handley
:Version: 1.0.0
:Homepage: https://github.com/williamjameshandley/py2nb.. image:: https://badge.fury.io/py/py2nb.svg
:target: https://badge.fury.io/py/py2nb
:alt: PyPi locationDescription
===========``py2nb`` is a python package for converting python scripts with minimal
markdown to jupyter notebooks.Markdown cells are rendered from comments beginning with ``#|``, splits between
code cells are created by comment lines beginning with ``#-````nb2py`` converts from jupyter notebooks to python
Installation
============Users can install using pip:
.. code:: bash
pip install py2nb
from source:
.. code:: bash
git clone https://github.com/williamjameshandley/py2nb
cd py2nb
python setup.py installor for those on `Arch linux `__ it is
available on the
`AUR `__Example
=======If one has a script named ``example.py`` containing the code:
.. code:: python
#| # Testing ipython notebook
#| This is designed to demonstrate a simple script that converts a script into
#| a jupyter notebook with a simple additional markdown format.
#|
#| Code by default will be put into code cells
#|
#| * To make a markdown cell, prefix the comment line with with '#|' or '# |'
#| * To split a code cell, add a line beginning with '#-' or '# -'import matplotlib.pyplot as plt
import numpy as np%matplotlib inline
#| Here is a markdown cell.
#| Maths is also possible: $A=B$
#|
#| There are code cells below, split by `'#-'`:# | Here is another markdown cell
x = np.random.rand(5)
#-------------------------------
y = np.random.rand(4)
z = np.random.rand(3)#| Here are some plots
x = np.linspace(-2,2,1000)
y = x**3
fig, ax = plt.subplots()
ax.plot(x,y)# -------------------------------
# | Here is another plot
x = np.linspace(-np.pi, np.pi, 201)
fig, ax = plt.subplots()
ax.plot(x,np.sin(x))then running
.. code :: bash
py2nb example.py
produces the notebook `example.ipynb `_
To do
=====
- evaluation option for script produced
- vim syntax highlighting for markdown code blocks