Keep jupyter number if you remove output - jupyter-notebook

Is it possible to keep the cell number when you remove a jupyter cell output?
The cell number disappear when you remove the output (see image.)

Instead of removing the output, you can hide the output just by double-clicking the Out[]. So that, the cell number will not be disappeared.

Related

why columns of csv file are shifting one cell to the right after downloading?

I have a csv file, on which i am running a R script.While previewing the file in google mail, the first cell is having value ";User". After getting downloaded, the the first cell is empty and the ";User " along with other column names is shifting by one cell to right.
Does anybody have a clue , as why it may happen?

Headings not working in my R markdown file

I recently finished my R notebook, and noticed something once I decided to knit the markdown file. None of the headings or bullet points were working! I had to install XQuartz to finish knitting the markdown file since I have a mac. Is this something that's normal or can I fix this?
I haven't seen your rmarkdown, but I suspect that you need to add a blank line above each heading. For example, putting a heading right after a list (or any other structure) sometimes results in problems:
1. First item
2. Second item
3. Third item
# First level heading
However, adding a blank line before each heading usually fixes the problem:
1. First item
2. Second item
3. Third item
# First level heading

How to insert multiple lines of highlighted text into Atom's platformio-ide-terminal?

I installed platformio-ide-terminal package in Atom. When I highlight and send multiple lines of text to my ipython terminal, it only runs the line where my cursor is blinking on.
Is there a way to send multiple lines of selected text?
If the lines are a complete statement, they must be separated by a semicolon. So you'd have to scroll back over the lines to insert a semicolon. If it is a single line that is too long to fit in a single terminal line, ipython should recognize this and generate '...' before the following lines as shown below.

How to copy multiple input cells in Jupyter Notebook

Basically I want to copy (Ctrl+C) only the code portions from multiple cells without also copying the output or the In[1]: and Out[1]:
What is the easiest way to do so?
When you are on a cell in Command mode(blue color mode), simply press Shift + DownArrow or Shift + UpArrow to select multiple cells. Press ctrl + C. And that's it. You have copied your entire selected code at once. It doesn't affect whether you have cell outputs.
Command mode: The Jupyter Notebook has two different keyboard input modes. Edit mode allows you to type code or text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level commands and is indicated by a grey cell border with a blue left margin.
In jupyter you can copy several cells or the content of one cell. If you follow #BenWS comment you can copy several cells, and if you do kernel > restart & clear outputs beforehand you woult not get the [out]. Shortcut is C for copy cell and V shift + V to paste below / above.
However if you intend to copy several cells content, you should merge then before by select them and shift + M and then you can copy paste with ctrl + C.
What worked for me is the following:
update jupyter notebook within a cell using:
pip install -U jupyter notebook
go in command mode by clicking to the left of a cell. If you click inside of a cell, it will be green.
Use shift+down/up to select the cells you want to copy and use ctrl+c
Now the most important one: make sure the jupyter file you want to copy the cells into is ALSO in blue/command mode. If this is not the case, you will copy all the cells into a single cell.
Just do:
File > Export Notebook As > Export Notebook to Asciidoc
and it will be easy to copy paste.
This is what an Asciidoc file looks like:
+*In[ ]:*+
[source, ipython3]
----
import pandas as pd
df = pd.read_csv("data/survey_results_public.csv")
df.tail(10)
df.shape
pd.set_option("display.max_columns", 85)
pd.set_option("display.max_rows", 85)
schema_df = pd.read_csv("data/survey_results_schema.csv")
schema_df.head(10)
----
In the latest version of JupyterLabs:
File > Export Notebook As > Executable Script
Gives you the code as a text file.
Open notebook dir as project in PyCharm, and then open the wanted ipynb file, select and copy all the source code, past into notepad++, replace "\r\n#%%\r\n\r\n" by null with extended search mode.
For jupyterlab after Shift + UpArrow or Shift + select with mouse on multiple cells. Right click on cells for copy(C) and paste(P).

How to write text in jupyter / ipython notebook?

Here is an example of IPython notebook in which besides the input and output cells we have a plain text. How can I do the same in my IPython notebook? At the moment I have inly In and Out cells.
Change the cell type to Markdown in the menu bar, from Code to Markdown. Currently in Notebook 4.x, the keyboard shortcut for such an action is: Esc (for command mode), then m (for markdown).
As it is written in the documentation you have to change the cell type to a markdown.
Step 1: Click on the '+' to create a new cell, type some text in, and select 'Markdown' in the dropdown
Step 2: It should now look like this:
Step 3: Click anywhere in the cell and click on 'Run'. Now it looks how you expect it to.
Simply Enter Esc and type m it will convert to text cell.
Adding to Matt's answer above (as I don't have comment privileges yet), one mouse-free workflow would be:
Esc then m then Enter so that you gain focus again and can start typing.
Without the last Enter you would still be in Escape mode and would otherwise have to use your mouse to activate text input in the cell.
Another way would be to add a new cell, type out your markdown in "Code" mode and then change to markdown once you're done typing everything you need, thus obviating the need to refocus.
You can then move on to your next cells. :)

Resources