Как скрыть конкретную ячейку / ячейки из вывода записной книжки python jupyterlab, используя команду кода внутри ячейки - PullRequest
0 голосов
/ 18 апреля 2020

Мне интересно, как нужно go скрыть вывод ячейки от отчетов, сгенерированных из записной книжки.

Записная книжка:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Hide a cell"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Numbers 1 to 5, with code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,6):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Numbers 1 to 5, without code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "# This cell should be hidden from the output\n",
    "for i in range(1,6):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (hide-cell-testing)",
   "language": "python",
   "name": "hide-cell-testing"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

Что выглядит как:

py

HTML создается с использованием:

jupyter nbconvert *.ipynb

И выглядит как:

enter image description here

Идеальным решением было бы что-то вроде

%%hidden_cell
for i in range(1,6):
    print(i)

Решения, нацеленные на jupyterlab (а не на ноутбук Jupyter), хороши. Если есть один, который работает на обоих, это хорошо, но я в основном заинтересован в jupyterlab.

...