jupyter-notebook

jupyter-notebook: add css class to output cell

。_饼干妹妹 提交于 2019-12-10 19:21:09
问题 Is it possible to add a class to the output cell using cell magic? For example: In [1]: %%css-class highlight display(pd.DataFrame(np.random.rand(3,4))) and then the the cell Out [1] will have the class "highlight" so that I can change the format using css. 回答1: After some search, I found this approach: First we import: from IPython.display import Javascript Then in some cell: x = pd.DataFrame(np.random.randn(3, 8), list('ABC'), list('abcdefgh')) display(x) display(x) Javascript('this.element

timing in python with %timeit %%timeit how to keep/retain values for later use

无人久伴 提交于 2019-12-10 18:38:47
问题 I am trying to measure the execution time of different parts of my code, a few lines each. I am doing this with %%timeit, however after I execute a cell, I find that the values calculated for variables in the cell are not kept in memory for next cells, as in the following example. Why does this happen? Is there a way to retain the values so I can use them in the rest of the program? In [1]: %%timeit ...: dog='dog' 100000000 loops, best of 3: 16.2 ns per loop In [2]: print (dog) --------------

Jupyter Notebook - GPU

北战南征 提交于 2019-12-10 18:14:18
问题 I'm working on a Jupyter Notebook and would like to make it run faster by using Google GPU. I've already made a few researches and found a solution, but it didn't work for me. The solution was: "Easiest way to do is use connect to Local Runtime then select hardware accelerator as GPU as shown in Google Colab Free GPU Tutorial." I did manage to connect googe colab to jupyter but when I then try to switch the hardware accelerator to GPU, I get disconnected from my jupyter notebook... In the

Anaconda 4.3, 64-bit (python 3.6), leaves incorrect truncated paths in windows Start menu

和自甴很熟 提交于 2019-12-10 18:09:39
问题 After installing anaconda 4.3 64-bit (python 3.6) on windows, and choosing "install for current user only" and "add to path": I noticed that the anaconda program shortcuts don't work on my start menu--they are cut off at the end. Does anyone know how the correct entries should read? (or instead, how to repair the links?) thanks. UPDATE: I reproduced the problem on two other machines, Windows 10 (x64) and windows 8.1 (x64), that were "clean" (neither one had a prior installation of python).

%% Cell magic tag not working in Jupyter notebook?

吃可爱长大的小学妹 提交于 2019-12-10 17:47:31
问题 I'm new to Jupyter notebook and I'm trying to set one up with Python and R, using rpy2. I have the line %%R -i df which gives me the error SyntaxError: invalid syntax However when I use just one %, such as %R require(ggplot2) this works fine. How can I fix this issue? I am using Python 2.7. 回答1: % prefix is for a line magic, whereas %% prefix is for a cell magic. %%R # <-- must be the only instruction on this line {body of cell in R code} whereas: %R {one line of R code} I don't have R

Jupyter notebook password not working from SSH

限于喜欢 提交于 2019-12-10 17:27:22
问题 Trying to connect to a Jupyter Notebook through SSH. I have a script which logs in to machine through SSH: #!/usr/bin/expect -f spawn ssh -L localhost:4000:localhost:8889 user@sshaddress.com expect "assword:" send "password\r" interact Set the jupyter password: jupyter notebook password # set it to something Then I run jupyter: jupyter notebook --no-browser --port=8889 Then I open my localhost:4000 and get the jupyter login page. However, putting in the password here only gives 'Invalid

Using Anaconda Distribution, how to use bokeh plotting?

心已入冬 提交于 2019-12-10 17:12:32
问题 Note from maintainers: This question concerns the obsolete first generation Bokeh server. For details about modern Bokeh server applications, see: https://docs.bokeh.org/en/latest/docs/user_guide/server.html OBSOLETE: I downloaded the Anaconda installer for Windows 32 bit from https://www.anaconda.com/distribution/ In my Jupyter Notebook, I inserted code from here: https://github.com/bokeh/bokeh/blob/demo/examples/plotting/server/remotedata.py Executing in the notebook draws that error: -----

Python & Pandas: Strange behavior when Pandas plot histogram to a specific ax

北城余情 提交于 2019-12-10 16:45:47
问题 I want to plot pandas histogram to an axis, but the behavior is really strange. I don't know what's wrong here. fig1, ax1 = plt.subplots(figsize=(4,3)) fig2, ax2 = plt.subplots(figsize=(4,3)) fig3, ax3 = plt.subplots(figsize=(4,3)) # 1. This works df['speed'].hist() # 2. This doens't work df['speed'].hist(ax=ax2) # 3. This works data = [1,2,3,5,6,2,3,4] temp_df = pd.DataFrame(data) temp_df.hist(ax=ax2) The error jupyter notebook returns is: AssertionError Traceback (most recent call last)

How should Jupyter extensions be installed and enabled for being reproducible?

谁说胖子不能爱 提交于 2019-12-10 15:42:45
问题 I'd like to make interactive slide set (for a presentation with some live coding in python) with RISE a.k.a. live_reveal, which is a notebook extension for Jupyter. I'd like the slide set to be usable by others (and by my future self) without too many manual steps (and without relying on hosted Jupyter solutions), thus I've chosen pipenv to manage dependencies. I can get started with pipenv install RISE pipenv run jupyter nbextension install rise --py --sys-prefix pipenv run jupyter

run Cython in Jupyter cdef

点点圈 提交于 2019-12-10 15:37:21
问题 I am looking for incorporate some cython to speed my code. I get a issue with running cython code in Jupyter. cell 1: %%cython cdef fuc(): cdef int a = 0 for i in range(10): a += i print(a) cell 2: fuc() error: --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-48-10789e9d47b8> in <module>() ----> 1 fuc() NameError: name 'fuc' is not defined but if i do this, it works fine. %%cython def fuc(): cdef int a = 0