ipython

Matplotlib magic in Jupyter notebook

时光怂恿深爱的人放手 提交于 2021-01-28 19:32:24
问题 When i am using the magic %matplotlib notebook it shows the follwing warning: Warning: Cannot change to a different GUI toolkit: notebook. Using gtk3 instead. What is the reason for this warning and how to get rid of it. 来源: https://stackoverflow.com/questions/61625435/matplotlib-magic-in-jupyter-notebook

sys.path and sys.executable is incorrect in jupyter, but no applied fix is working

a 夏天 提交于 2021-01-28 07:52:35
问题 I've configured jupyter to be used from a remote computer and set a password to it while initial anaconda setup. Then after fixing this issue, I am trapped in another one. sys.path and sys.executable is incorrect in jupyter , but correct in python and ipython . Please see the details below. Anaconda3 is installed for all users in /opt/anaconda3 and I am using an environment zud for my programs. Background Once the above-mentioned problem is fixed, I tried to import igraph in jupyter but it

Pandas Column/Index Values With Dollar Signs

落花浮王杯 提交于 2021-01-28 04:53:38
问题 Given the following data frame: import pandas as pd df=pd.DataFrame({'A':['$0-$20','$20+']}) df A 0 0−20 1 $20+ How can I get the first value (0-20) to display with the dollar signs, as I originally specified? It actually displays the zero in a strange font and I'm not sure why it works for "$20+" but not "$0-"$20". I've tried: df=pd.DataFrame({'A':[str('$0-$20'),'$20+']}) ...but no dice. Here's specifically what I get: I'm using the Jupyter notebook (Anaconda 3, Python 3.5) Thanks in advance

Jupyter: Programmatically Clear Output from all Cells when Kernel is Ready

ε祈祈猫儿з 提交于 2021-01-28 04:45:31
问题 I have a question on how to programmatically clear\clean the output from all the Cells in my Jupyter notebook after notebook is done loading (when Kernel is ready), and prior to the user, myself, manually executing code. Basically, I would like the notebook to look clean when it is done loading, and I would like to do it automatically. How can I impose a command like clear_output() from a single initialization cell on to all other cells in the notebook? Thank you. 回答1: For a trusted notebook

Jupyter: Programmatically Clear Output from all Cells when Kernel is Ready

孤者浪人 提交于 2021-01-28 04:27:41
问题 I have a question on how to programmatically clear\clean the output from all the Cells in my Jupyter notebook after notebook is done loading (when Kernel is ready), and prior to the user, myself, manually executing code. Basically, I would like the notebook to look clean when it is done loading, and I would like to do it automatically. How can I impose a command like clear_output() from a single initialization cell on to all other cells in the notebook? Thank you. 回答1: For a trusted notebook

%timeit and re-assignment of variable

五迷三道 提交于 2021-01-28 02:50:55
问题 Surprising ipython magic %timeit error: In[1]: a = 2 In[2]: %timeit a = 2 * a Traceback (most recent call last): File "...\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-97-6f70919654d1>", line 1, in <module> get_ipython().run_line_magic('timeit', 'a = 2 * a') File "...\site-packages\IPython\core\interactiveshell.py", line 2314, in run_line_magic result = fn(*args, **kwargs) File "<...\site

Scientific/Exponential notation with sympy in an ipython notebook

谁都会走 提交于 2021-01-27 23:11:00
问题 How is the threshold for scientific notation set in an ipython notebook? I want to set all number outisde of something like [0.01, 100] to be printed in scientific notation, but the threshold seems to be much higher. i.e. In [165]: x = sympy.Symbol('x'); 1.e8*x Out[165]: 100000000.0*x but In [166]: 1.e28*x Out[166]: 1.0e+28*x Because I'm using sympy, I can't send the number to a formatted print statement, i.e. In [167]: print "%.2e" % (1.e8*x) ERROR: TypeError: float argument required, not

IPython automatically turning on matplotlib interactive mode

a 夏天 提交于 2021-01-27 18:52:51
问题 I'm experiencing some newly odd behavior from IPython. I just had to do a clean reinstall of my miniconda, so I now have fresh IPython and Matplotlib versions. It turns out that IPython is automatically switching matplotlib to interactive mode (which has the annoying side effect of making my saved figures blank in my scripts, because they save after I close the window). Here's an example: Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21) Type 'copyright', 'credits' or

Plotting data from generator in Python

泪湿孤枕 提交于 2021-01-27 16:31:12
问题 Is there any plotting option in Python (IPython-Jupyter notebook) which accepts generators ? AFAIK matplotlib doesn't support that. The only option I discovered is plot.ly with their Streaming API, but I would prefer not to use online solution due to big amount of data I need to plot in real-time. 回答1: A fixed length generator can always be converted to a list. vals_list = list(vals_generator) This should be appropriate input for matplotlib . Guessing from your updated information, it might

kernel keeps dying in jupyter notebook

那年仲夏 提交于 2021-01-26 21:51:25
问题 Whenever I start jupyter notebook and create a new python 3 notebook I get an error message saying kernel has died. I have tried deleting and installing ipython, python3.6.5, and jupyter notebook but I still get the error message. My cmd screen is as follows:- [I 06:46:36.432 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports WARNING:root:kernel 0d0442a9-c92f-46e6-acdd-08ca0a18c5f2 restarted Traceback (most recent call last): File "c:\users\user\appdata\local\programs