Loading...
Loading...
Read, modify, execute, and convert Jupyter notebooks programmatically. Use when working with .ipynb files for data science workflows, including editing cells, clearing outputs, or converting to other formats.
npx skill4agent add openhands/skills jupyternb['cells']sourcecell_typeimport json
with open('notebook.ipynb') as f:
nb = json.load(f)
# Modify nb['cells'][i]['source'], then:
with open('notebook.ipynb', 'w') as f:
json.dump(nb, f, indent=1)jupyter nbconvert --to notebook --execute --inplace notebook.ipynb # Execute in place
jupyter nbconvert --to html notebook.ipynb # Convert to HTML
jupyter nbconvert --to script notebook.ipynb # Convert to Python
jupyter nbconvert --to markdown notebook.ipynb # Convert to Markdowngrep -n "search_term" notebook.ipynb# Code cell
{"cell_type": "code", "execution_count": None, "metadata": {}, "outputs": [], "source": ["code\n"]}
# Markdown cell
{"cell_type": "markdown", "metadata": {}, "source": ["# Title\n"]}for cell in nb['cells']:
if cell['cell_type'] == 'code':
cell['outputs'] = []
cell['execution_count'] = None