Copy data from Jupyter notebook

限于喜欢 提交于 2019-12-11 01:08:04

问题


I would like to copy and paste data from a Jupyter notebook. As per the following example which includes the In and Out elements.

When trying to copy this data I am currently unable to select the In and Out elements as these are not contained in the cell data.

In [23]:
df.index.slice_indexer(start_remove, end_remove)

Out[23]:
slice(36, 85, None)

This image shows the In and Out elements as well as the cells. I want to copy and paste all of this.


回答1:


Less ugly hack:

You can do this in console of Inspection Tool:

$('div.prompt').removeClass('prompt')

And you don't have to refresh the page. You can carry on your coding with the prompt class removed from all the div elements. And you can select what you want at all times. But if you create new cells, you will have to run that again.


Ugly hack:

Steps:

  1. Right click on In [number] in your browser and click on Inspect Element

You will see something like this:

`<div class="prompt input_prompt">In&nbsp;[18]:</div>`
  1. Double click on class and remove the prompt class from the div element. After removing it, it will look like this:

    <div class="input_prompt">In&nbsp;[18]:</div>

  2. Press Enter and close the inspection tool.

  3. Now click and select from left of I in In [] and drag your mouse inside the code block.

  4. Voila! You got what you wanted.

  5. You can replace prompt back or just refresh the page.



来源:https://stackoverflow.com/questions/41520415/copy-data-from-jupyter-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!