jupyter-notebook

How to stop the running cell if interupt kernel does not work in jupyter notebook

*爱你&永不变心* 提交于 2020-01-12 11:47:10
问题 I'm using jupyter notebook for a while. Often when I tried to stop a cell execution, interrupting kernel did not work. In this case, what else can I do, other than just closing the notebook and relaunch again? I guess this might be a common situation for many people. thanks a lot. 回答1: If you're ok with losing all currently defined variables, then going to Kernel > Restart will stop execution without closing the notebook. 回答2: Currently this is an issue in the github jupyter repository as

Using Ipython ipywidget to create a variable?

寵の児 提交于 2020-01-12 04:38:29
问题 This seems really simple but I have not been able to find a single example or to solve this myself. How do I use an ipywidget widget to create or return a python variable/object, such as a list or string, that can be used in a following cell? 回答1: There is a good introduction to ipywidgets at http://blog.dominodatalab.com/interactive-dashboards-in-jupyter/ which answers this question. You need two widgets, one for input, and another to bind the value of that input. Here's an example for text

Jupyter: Write a custom magic that modifies the contents of the cell it's in

限于喜欢 提交于 2020-01-12 02:20:28
问题 In a Jupyter notebook there are some built-in magics that change the contents of a notebook cell. For example, the %load magic replaces the contents of the current cell with the contents of a file on the file system. How can I write a custom magic command that does something similar? What I have so far prints something to stdout def tutorial_asset(line): print('hello world') def load_ipython_extension(ipython): ipython.register_magic_function(tutorial_asset, 'line') And I can load it with

Jupyter: Write a custom magic that modifies the contents of the cell it's in

倾然丶 夕夏残阳落幕 提交于 2020-01-12 02:20:04
问题 In a Jupyter notebook there are some built-in magics that change the contents of a notebook cell. For example, the %load magic replaces the contents of the current cell with the contents of a file on the file system. How can I write a custom magic command that does something similar? What I have so far prints something to stdout def tutorial_asset(line): print('hello world') def load_ipython_extension(ipython): ipython.register_magic_function(tutorial_asset, 'line') And I can load it with

Import a Jupyter Notebook in HTML format

假装没事ソ 提交于 2020-01-11 13:40:06
问题 My colleague worked on a Jupyter notebook using R and exported it as an html file. I can view the html file. However, can I open it as a Jypyter notebook and directly modify it? I do not want to copy and paste everything in the html file to a new Jupyter notebook by hand... Thanks! 来源: https://stackoverflow.com/questions/59552207/import-a-jupyter-notebook-in-html-format

Import a Jupyter Notebook in HTML format

爷,独闯天下 提交于 2020-01-11 13:38:35
问题 My colleague worked on a Jupyter notebook using R and exported it as an html file. I can view the html file. However, can I open it as a Jypyter notebook and directly modify it? I do not want to copy and paste everything in the html file to a new Jupyter notebook by hand... Thanks! 来源: https://stackoverflow.com/questions/59552207/import-a-jupyter-notebook-in-html-format

Assigning dtype value using array.dtype = <data type> in NumPy arrays gives ambiguous results

我怕爱的太早我们不能终老 提交于 2020-01-11 10:21:55
问题 I am new to programming and numpy... While reading tutorials and experimenting on jupyter-notebook... I thought of converting dtype of a numpy array as follows: import numpy as np c = np.random.rand(4)*10 print c #Output1: [ 0.12757225 5.48992242 7.63139022 2.92746857] c.dtype = int print c #Output2: [4593764294844833304 4617867121563982285 4620278199966380988 4613774491979221856] I know the proper way of changing is: c = c.astype(int) But I want to the reason behind those ambiguous numbers

Assigning dtype value using array.dtype = <data type> in NumPy arrays gives ambiguous results

落花浮王杯 提交于 2020-01-11 10:21:51
问题 I am new to programming and numpy... While reading tutorials and experimenting on jupyter-notebook... I thought of converting dtype of a numpy array as follows: import numpy as np c = np.random.rand(4)*10 print c #Output1: [ 0.12757225 5.48992242 7.63139022 2.92746857] c.dtype = int print c #Output2: [4593764294844833304 4617867121563982285 4620278199966380988 4613774491979221856] I know the proper way of changing is: c = c.astype(int) But I want to the reason behind those ambiguous numbers

Interactive matplotlib using ipywidgets

戏子无情 提交于 2020-01-11 04:39:08
问题 I want to implement an interactive plot using Matplotlib and ipywidgets in IPython (python3). So, how I can do this efficiently (change smoothly without delay)? And another question is why this code works?! from ipywidgets import * import numpy as np import matplotlib.pyplot as plt %matplotlib inline x = np.linspace(0, 2 * np.pi) def update(w = 1.0): fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.plot(x, np.sin(w * x)) fig.canvas.draw() interact(update); But, this doesn't work?! from

Finding the element in one array corresponding to the maximum value in another

爱⌒轻易说出口 提交于 2020-01-07 02:03:38
问题 How can I align the 4d z array and the 4d QCLOUD array and to then find out the z value of when QCLOUD max occurs? print(z.shape) print(qcloud.shape) out: (6, 100, 128, 128) (6, 99, 128, 128) 回答1: Ignoring the fact that (np.array(z.shape) > np.array(qcloud.shape)).any() , you want argmax : idx = np.argmax(qcloud) result = z[tuple(idx)] 来源: https://stackoverflow.com/questions/37446740/finding-the-element-in-one-array-corresponding-to-the-maximum-value-in-another