Jupyer notebook: Clicked 3 and all output is gone? - python

Apparently when you type 3 in jupyter notebook the focused cell is turned into markdown and all output is gone, incredible... Now all progress I've done for 20 hours is gone. Any way to fix this? If it's not fixable this is a huge fault in jupyter. No single button should be able to destroy the work like that.
Also in tab-view the cell is still working but nothing inside the document says it is, and I get no output.

Related

my jupyter notebook is pasting unncessary program lines inbetween

when I try to write any code jupyter notebook automatically paste any irrelevant / sometimes relevant program between the program, but I want to stop this shit, because it is irritating me. suggestions are different things. but this issue has arrived in my notebook for the past few days.you can see in this link exactly what happening in this link
how can I get rid of it? please help me out. The error lines are in green color whereas normal program looks like thisSee this line in grey color is suggested by notebook
I am just confused. I don't know how it started. I didn't get any solution on it anywhere
looks like https://discourse.jupyter.org/t/jupyter-notebooks-annoying-grey-text-auto-show/16886/5, This is most likely a browser issue, what browser are you using? any extentions that could cause this? maybe try switching browsers?

Can't open ipynb juypter notebook file, crashed on a large df

Panicking.
Spend a long time working on code in Juypter Notebook on macbook (Anaconda) and i accidentally performed df.fillna(0) on a large df, not knowing it was going to try and load the whole thing in Juypter (i have it set to display all)
It crashed and was unresponsive. Now it's closed and won't load again (i just get the header UI stuff and nothing else - a bar at the top of the webpage shows loading progress but then stalls). The kernel is grey.
Have I just lost all my work? Other files are working as normal. Just managed to get it to partially load (shows me the first couple of cells but page is unresponsive) and i click interupt kernel in a panic to try and get it to just leave me with the code and stop trying to load anything. No luck yet.
Is there any way of retrieving my code? I don't care about any calculations
Thanks
Jupyter notebooks are just stored as JSON. You should be able to open it in a text editor and just pull out the code fields. – answer provided by jprebys
Oct 21 at 13:35

Underline abruptly appears and deletes the code. How can I prevent this?

Sometimes when I'm editing python code in Jupyter Notebook, an underline abruptly appears.
I'm trying to edit the code anyway, then the underlined code is deleted when I click it or try to make a selection of some part of the code with Shift button on the keyboard or dragging of the mouse. I tried Ctrl+A to select and copy the whole code but Ctrl+A deleted the whole code.
Actually I don't know what is happening. I don't know exactly how I created the underline or how I deleted the underlined code, hence, I cannot prevent it from happening.
I'm new to Python and Jupyter and trying to use it.
But this has already happened 3-4 times. Please help me.
I had the same issue today and I didn't know why, that's the reason I find this post.
However, I was able to recover with the following method:
1, hold the Crtl + z, not the single click, and the deleted content will be back.
2, once you got everything deleted back, save the notebook and reopen it.

In Jupyter notebook, can the "enable scrolling" window auto-scroll down to keep up pace with the output?

I often write functions that print a lot, say every 100th go-around a long loop, which in the Terminal run fine, because my screen auto-scrolls down with the output; but on Jupyter, the output quickly moves downward, and I have to scroll down myself to keep up with it. This happens whether I'm in the "enable scrolling" or "disable scrolling" for the output.
So, my Q is: Is there a way to have Jupyter auto-scroll down with the output? I suppose this would make more sense inside of a scroll window (i.e. "enable scrolling".) Auto-scrolled output would give a more Terminal-like experience, which I am much more familiar and comfortable with. (And, to be honest, I also miss my The-Matrix-like aesthetic of streaming output.)
If it matters, I use Jupyter Lab primarily, but I believe the same is true on Jupyter Notebook.
Thanks so much, all!
nbextensions has an auto-scroll extension to do just that, though its incompatible with jupyter lab at the moment.
https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/autoscroll/README.html

Ipython Notebook: Elegant way of turning off part of cells?

In my ipython notebook, there is part of cells that serves as preliminary inspection.
Now I want to turn it off, since after running it I know the status of the dataset, but I also want to keep it, so other people using this notebook can have this functionality.
How can I do it? Is there any example of doing it?
I can comment out these cells, but then switching between on and off would be quite laborious. And may not be quite convinent for other people.
I can abstract it into a function, but that itself has some methods, so the code would be quite convoluted, and may be hard to read?
Using Jupyter notebook you can click on a cell, press esc and then r. That converts it to a "raw" cell. Similar thing can be done to convert it back, esc + y. No comments needed, just key presses.
Within Jupyer notebook, go to Help -> Keyboard shortcuts for more.
Here's a snippet:
Command Mode (press Esc to enable)
↩ : enter edit mode
⇧↩ : run cell, select below
⌃↩ : run cell
⌥↩ : run cell, insert below
y : to code
m : to markdown
r : to raw
In Jupyter notebooks one can use this magic preamble at the beginning of a cell to avoid its execution:
%%script false --no-raise-error
You can use a condition at the cost of one extra indentation.
cellEnabled = 0
#cellEnabled = 1
if cellEnabled:
doA()
doB()
I had the same kind of desire and I eventually found out about the nbextension called Freeze. When you enable it, you get a nice freeze button in your toolbar. When you click it, the cell you're currently in will become "frozen". This means it will turn green (making it visually clear) and it will be ignored by the Run All process. It's also locked for editing, so you do need to unfreeze it (unlock button, two over to the left of the freeze button) before editing or running the cell. That's really easy to do though because it's just one button.
Let me know if this wasn't super clear. Otherwise, I hope this helps!

Categories