ipython-notebook

Jupyter notebook kernel dies when creating dummy variables with pandas

孤街浪徒 提交于 2019-12-05 09:50:43
I am working on the Walmart Kaggle competition and I'm trying to create a dummy column of of the "FinelineNumber" column. For context, df.shape returns (647054, 7) . I am trying to make a dummy column for df['FinelineNumber'] , which has 5,196 unique values. The results should be a dataframe of shape (647054, 5196) , which I then plan to concat to the original dataframe. Nearly every time I run fineline_dummies = pd.get_dummies(df['FinelineNumber'], prefix='fl') , I get the following error message The kernel appears to have died. It will restart automatically. I am running python 2.7 in

Executing Javascript cells in Jupyter Notebooks

人走茶凉 提交于 2019-12-05 09:47:57
I'm seeing some strange behavior using Javascript cells in a (trusted) Jupyter notebook. For example, I can execute the following cells, intended to fetch the current URL of the notebook. %%javascript var kernel = IPython.notebook.kernel; var thename = window.location.href; var command = "notebook_url = " + "'"+thename+"'"; kernel.execute(command); And now I try to access the variable in another cell: print notebook_url This works as expected with I run the cells one after another (Shift + Enter), but throws a NameError: name 'notebook_url' is not defined when I try to 'Run All' cells. How

Convert SVG to png or other?

蓝咒 提交于 2019-12-05 08:52:35
Since it's very easy to display the content of a SVG file inside the iPython notebook, is there also a way (easy too) to get what we see inside a png file or other ? from IPython.display import SVG SVG(filename='../images/python_logo.svg') If I do svg = SVG(filename='../images/python_logo.svg') How can I save it to a png file ? SVG are vectors images (the drawings are saved as commands to draw lines, circles, etc). PNGs are bitmaps. So to convert SVG to PNG, you need a renderer. The most obvious solution is ImageMagick, a library you have already installed, as it is used in several programs. A

Disable Jupyter Keyboard Shortcuts

好久不见. 提交于 2019-12-05 07:40:50
One of my Jupyter notebooks uses an html <input> tag that expects typed user input, but whenever I type in the text box, command mode keyboard shortcuts activate. Is it possible to turn off keyboard shortcuts for a single cell or notebook? You could copy paste this line into your custom.js: $([IPython.events]).on("app_initialized.NotebookApp", function () { ... // Starting from this line, replace 'Shift-k' with whatever // shortcut you're trying to remove. IPython.keyboard_manager.command_shortcuts.remove_shortcut('Shift-k') ... }); Or whatever shortcut you wish to remove. Source: http:/

ipython notebook on remote server peculiarity

感情迁移 提交于 2019-12-05 06:51:14
问题 I am taking my first steps with ipython notebook and I installed it successfully on a remote server of mine (over SSH) and I started it using the following command: ipython notebook --ip='*' ---pylab=inline --port=7777 I then checked on http://myserver.sth:7777/ and the notebook was running just fine. I then wanted to close the SSH connection with the server and keep ipython running in the background. When I did this, I couldn't connect to myserver.sth:7777 anymore. Once I connected again to

repl in webpage, best way to go about it?

送分小仙女□ 提交于 2019-12-05 06:39:33
问题 OK, so I am experimenting with a simple python repl in a browser. I want to put some python code in a text input, and then hit the 'send' button, then get back the result of evaluating it. I was using flask, with one route, which called the stdlib eval function, and then sends it back. I was also using zeroMQ with a simple server/client setup. I feel like I am missing something though... How is the standard way to go about doing this kind of thing? Projects like repl.it and skulpt are doing

How to recover a notebook emptied after kernel crash?

馋奶兔 提交于 2019-12-05 03:49:54
While working in an ipython notebook, eventually I had to Ctrl+C as the kernel seemed to be halted. The console gave me a message like: [NotebookApp] Kernel shutdown: 5faa86bf-........f6 [NotebookApp] Kernel shutdown: 71........22 [NotebookApp] .... (I had three notebooks running) But something went wrong and my notebook file.ipynb is empty (actually only the one I was actively using). Is there a way to recover that file before it was deleted? Some place where automatically-saved o manually-saved versions are stored? (Running python 2.7 (Anaconda) in Windows 7) You can check in .ipynb

iPython - set up magic commands in configuration file

自作多情 提交于 2019-12-05 03:47:45
I use iPython mostly via notebooks but also in the terminal. I just created my default profile by running ipython profile create . I can't seem to figure out how to have the profile run several magic commands that I use every time. I tried to look this up online and in a book I'm reading but can't get it to work. For example, if I want %debug activated for every new notebook I tried adding these lines to my config file: c.InteractiveShellApp.extensions = ['debug'] or c.TerminalPythonApp.extensions = ['debug'] and I either get import errors or nothing. My (closely related) questions are the

How to get a latex table of sympy expressions in ipython-notebook?

你。 提交于 2019-12-05 03:12:27
问题 I'm using sympy to collect terms from several expressions and would like to format the results (within ipython-notebook) in a table with the terms down the left most column and each subsequent column representing one expression. The entries in the column are from the dict returned by sympy.collect(syms, evaluate=False) So far I have: from IPython.display import display, Latex import pandas as pd import sympy as sym sym.init_printing() x,y,z = sym.symbols('x,y,z') da,db,dc = sym.symbols('{

ipython notebook : how to parallelize external script

隐身守侯 提交于 2019-12-05 01:54:51
问题 I'm trying to use parallel computing from ipython parallel library. But I have little knowledge about it and I find the doc difficult to read from someone who knows nothing about parallel computing. Funnily, all tutorials I found just re-use the example in the doc, with the same explanation, which from my point of view, is useless. Basically what I'd like to do is running few scripts in background so they are executed in the same time. In bash it would be something like : for my_file in $(cat