Is it possible to create grouping of input cells i

2020-05-20 09:04发布

问题:

When I do data analysis on IPython Notebook, I often feel the need to move up or down several adjacent input cells, for better flow of the analysis story.

I'd expected that once I'd create a heading, all cells under that heading would move together if I move the heading. But this is not the case.

Any way I can do this?

Edit: To clarify, I can of course move cells individually, and the keyboard shortcuts are handy; but what I'm looking for is a way to group cells so that I can move (or even delete) them all together.

回答1:

I use a little-known extension, which does exactly what you want (i.e. "once I'd create a heading, all cells under that heading would move together if I move the heading"). It is part of the Calico suite, but can be installed separately.

More specifically, you need to install a Calico Notebook Extension named Document Tools. From the description:

The Calico Document Tools extensions adds section moving, heading numbering, table of contents, and bibliography support. Demonstration of use: https://www.youtube.com/watch?v=YbM8rrj-Bms

I don't know whether the instructions of installation given on the wiki page are updated for IPython 3.0 (february 2015), but the source-code on BitBucket actually is.

I cannot install IPython 3.0 for the moment, but I gladly use this extension with IPython 2.x since last summer. It's great, perhaps less versatile than the asif.m's suggestion Collective Cut-Copy-Paste for IPython Notebooks (which, by the way, has not been updated for IPython 3.0), but IMHO faster and more logical.



回答2:

For anyone out there who needs the grouping feature: yes, there's a great extension here: https://github.com/ivanov/nb-cccp

The days of moving one cell at a time is over. Apparently it will be built into the next IPython version.



回答3:

This is not currently possible. There are two relevant issues open on Github:

  • Group multiple cells together as one unit using shift button #5180
  • Allow sections to be collapsed and expanded in the notebook #805


回答4:

Latest version of Ipython/Jupyter notebook allows selection of multiple cells using shift key which can be useful for batch operations such as copy, paste, delete, etc.