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

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

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?

Jupyer notebook: Clicked 3 and all output is gone?

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.

Cell stacking on each other in Jupyter dashboard view

I'm new to the Jupyter notebook. When I am moving to the dashboard grid layout, all off my cells are stack upon each other without any option of moving them. In addition, I can't go back to regular notebook view without reentering the notebook.
I've tried to play with the settings without success. Then I switched all my code to just 2 simple headings and it is still happening. Couldn't find any answers on the web.
Anyone has an idea how to solve it?

Messaging and Jupyter Notebooks

I'm trying to wrap my head around messaging in Jupyter notebooks. But I'm a bit lost and confused.
My goal is fairly straight forward to state: I want my python kernel to update the output of a cell in a Jupyter notebook while a long calculation is running. Whenever new data arrives in the browser, I want to trigger a redraw by calling some javascript function.
Specifically, the cell output contains HTML with a WebGL canvas. That part works well. I can easily visualize the initial data in the canvas with WebGL/javascript. But I want to update the data dynamically, as the kernel performs a long calculation on it. What I'd like to know is how one of my javascript functions in a notebook can receive binary data from my kernel.
I tried to read the documentation on messaging and jupyter notebooks, but it's really short and doesn't provide any links for further reading. What would really help is an example in the form of two code snippets, one for the notebook and the other for the kernel side.

iPython Notebook in Firefox - Warning: unresponsive script

I had a long script running on iPython notebook in Firefox for a long time. I came back and it seemed to have hung up, so I saved it and closed it.
When I re-open the script, I get a dialog box pop up with the following error:
Warning: unresponsive script
A script on this page may be busy, or it stack overflow may have
stopped responding. You can stop the script now, open the script in
the debugger, or let the script continue.
The options are 'continue', 'stop script' and 'debug script'. Clicking on any of these leads to the same result, the dialog box disappears and the iPython notebook is unresponsive (for example, ctrl+enter creates a line-break in the current cell rather than executing it).
Worst of all however, the cells at the bottom of the script seem to have been cut off. They contained some valuable code which seems to have gone, this is quite a bad outcome!
I've tried rolling back but the last roll-back point also shows the bottom cut off. Any support here much appreciated!
I have now worked this out and leave it here in the hope it will help others.
The cause of the problem seemed to be an excessively long output from one of the cells - everything below this line had been cut off in the iPython browser, but I discovered it still exists in the .ipynb file and all I had to do was remove some of the output lines, and when I re-opened the file it ran without problems AND my code that had been cut off was available once again.
The notebooks store everything in JSON format. In my case, I needed to remove output from one of the cells, which I did like this:
Browse to your iPython Notebooks directory (NOT where ipython.exe resides) - for me they were in C:\Users\myname\Documents\IPython Notebooks
Right-click on the offending notebook.ipynb file, and edit in a text editor - my choice is Notepad++
Scroll down to the cell which has generated lots of output lines. Each of these lines is inside the cell's outputs property, with "output_type": "stream"
Remove an arbitrary number of these output entries, but be sure to remove anything outside the output property itself, and be sure to remove from the back of a tailing comma to the front of the following comma so that the resulting JSON is well-formed
A typical line of output looks like this, deleting several hundred of them made my script run again in the browser:
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"Added 150000 records so far"
]
},
Maybe it's Firefox's fault.
Letting the script run longer
If you find that pressing the Continue button brings up the same dialog again, letting the script run longer won't help you; it will just make Firefox hang for longer. However, if you can use Firefox normally after pressing Continue, then the script may just needs extra time to complete.
To tell Firefox to let the script run longer:
In the Location bar, type about:config and press Enter. The about:config "This might void your warranty!" warning page may appear. Click I'll be careful, I promise! to continue to the about:config page.
In the about:config page, search for the preference dom.max_script_run_time, and double-click on it.
In the Enter integer value prompt, type 20.
Press OK.
With scripts now allowed to run for longer times, you may no longer receive the prompt.
This is from https://support.mozilla.org/en-US/kb/warning-unresponsive-script
Hope it could help.

Categories