Created
May 3, 2021 04:47
-
-
Save planetacomputer/281458690d0e632e3a2be13448a18b8d to your computer and use it in GitHub Desktop.
Jupyter - Delete all code cells except markdown text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nbformat as nbf | |
ntbk = nbf.read("Exercises_numpy.ipynb", nbf.NO_CONVERT) | |
cells_to_keep = [] | |
for cell in ntbk.cells: | |
if cell.cell_type == "markdown": | |
cells_to_keep.append(cell) | |
new_ntbk = ntbk | |
new_ntbk.cells = cells_to_keep | |
nbf.write(new_ntbk, "new_md_only_notebook.ipynb", version=nbf.NO_CONVERT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment