JupyterLabは:どのようにキーボードショートカットを使用して、現在のセルの出力をクリアするには?

Vestlnd:

この質問はJupyterを求めたと回答されているノートブック ここにそこJupyterに関する1つの提案であるラボは、どのようににそこにも非表示セルの出力が、それをクリアすることではありません。

これは、下のメニューを使用して簡単には十分ですEdit > Clear Outputsしかし、どのようにキーボードショートカットを使用してそれを行うのですか?下の他の多くのコマンドEditすでには、このいずれかを自分自身に割り当てられたショートカットを持っていますが、ありません。

ここでは、画像の説明を入力します。

Vestlnd:

答え:

あなたは、下のカスタムショートカットキーを割り当てる必要がありますSettings > Advanced Settings Editor下に以下を挿入することによりUser Preferences

{// List of Keyboard Shortcuts
    "shortcuts": [
        {
            "command": "notebook:clear-cell-output",
            "keys": [
                "F10"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        },
    ]
}

I went for F10, but most other keys or combination of keys should work too. I've also used Ctrl Shift Enter.

Where to put it:

ここでは、画像の説明を入力します。

Some details:

If you've assigned other shortcuts, make sure to add it in the correct place in the list of other shortcuts.

{// List of Keyboard Shortcuts
    "shortcuts": [
        {
            "command": "notebook:run-in-console",
            "keys": [
                "F9"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        },
        {
            "command": "notebook:clear-cell-output",
            "keys": [
                "F10"
            ],
            "selector": ".jp-Notebook.jp-mod-editMode"
        },
    ]
}

And a little mystery:

If you insert the exact same thing as in the second box, you'll see that the item Run > Run Selected Text or Current Line in Console has gotten a nice F9 right next to it:

ここでは、画像の説明を入力します。

This will not be the case for the item Edit > Clear Outputs, and I'll have to say that I don't know why.

ここでは、画像の説明を入力します。

To my knowledge the "command": "notebook:clear-cell-output" that you're assigning to your chosen keyboard shortcut should be that exact functionality. But the good thing is that it works perfectly all the same. At least it does for me.

このアプローチはJupyterLabの新しいバージョンに適していますのでご注意ください。正しい方法は、古いバージョンの少し異なるものになります。

ここでは、すぐにそれをテストするためのPythonの抜粋です:

import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
print(df)

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=282919&siteId=1