jupyter-notebook

Coroutine as background job in Jupyter notebook

安稳与你 提交于 2019-12-07 05:30:09
问题 I have a coroutine which I'd like to run as a "background job" in a Jupyter notebook. I've seen ways to accomplish this using threading, but I'm wondering whether it's also possible to hook into the notebook's event loop. For example, say I have the following class: import asyncio class Counter: def __init__(self): self.counter = 0 async def run(self): while True: self.counter += 1 await asyncio.sleep(1.0) t = Counter() and I'd like to execute the run method (which loops indefinitely), while

How to specify python3 kernel in jupyter in pyCharm?

 ̄綄美尐妖づ 提交于 2019-12-07 05:25:40
问题 Here is my setting and this is my script I am trying to use jupyter notebook in pyCharm, but it kept using python2 instead of python3. Any idea about this problem? Add: this pic is running jupyter notebook in chrome. 回答1: My problem was that I had multiple kernels, and PyCharm launches the default kernel. One approach might be to configure PyCharm to specify the kernel of choice to start up, I didn't investigate how to do that. I simply changed the default kernel in Jupyter and this worked

I am trying to run Dickey-Fuller test in statsmodels in Python but getting error

守給你的承諾、 提交于 2019-12-07 05:08:08
问题 I am trying to run Dickey-Fuller test in statsmodels in Python but getting error P Running from python 2.7 & Pandas version 0.19.2. Dataset is from Github and imported the same enter code here from statsmodels.tsa.stattools import adfuller def test_stationarity(timeseries): print 'Results of Dickey-Fuller Test:' dftest = ts.adfuller(timeseries, autolag='AIC' ) dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used']) for key,value in

Flush output in for loop in Jupyter notebook

[亡魂溺海] 提交于 2019-12-07 03:55:56
问题 I want to print out i in my iteration on Jupyter notebook and flush it out. After the next iteration, I'll print the next i . I tried solutions from this question and this question, however, it just print out 0123...9 without flushing the output for me. Here is my working code: import sys import time for i in range(10): sys.stdout.write(str(i)) # or print(i, flush=True) ? time.sleep(0.5) sys.stdout.flush() these are my setup: ipython 5.1, python 3.6. Maybe, I missed something in the previous

Print Visually Pleasing DataFrames in For Loop in Jupyter Notebook Pandas

喜夏-厌秋 提交于 2019-12-07 02:10:31
问题 Say I have these two Data Frames in a list, sm = pd.DataFrame([["Forever", 'BenHarper'],["Steel My Kisses", 'Kack Johnson'],\ ["Diamond On the Inside",'Xavier Rudd'],[ "Count On Me", "Bruno Mars"]],\ columns=["Song", "Artist"]) pm = pd.DataFrame([["I am yours", 'Jack Johnson'],["Chasing Cars", 'Snow Patrol'],\ ["Kingdom Comes",'Cold Play'],[ "Time of your life", "GreenDay"]],\ columns=["Song", "Artist"]) df_list = [sm,pm] Now, when I want to print both data frames while iterating, I get

Graphviz.Source not rendering in Jupyter Notebook

為{幸葍}努か 提交于 2019-12-06 22:02:24
问题 After exporting a .dot file using scikit-learn's handy export_graphviz function. I am trying to render the dot file using Graphviz into a cell in my Jupyter Notebook: import graphviz from IPython.display import display with open("tree_1.dot") as f: dot_graph = f.read() display(graphviz.Source(dot_graph)) However the out[ ] is just an empty cell. I am using graphviz 0.5 (pip then conda installed), iPython 5.1 , and Python 3.5 The dot file looks correct here are the first characters: digraph

A simple way to view ipython notebook

时光总嘲笑我的痴心妄想 提交于 2019-12-06 20:49:09
问题 I am really new to IPython/Jupyter notebook. I just created one notebook (.ipynb) and I want to share it on my webpage. Specifically, I want to add a link, and when people click it, it will open a new "webpage" where they can "view" my code and results. Note: I cannot use github, it is a huge pain for me. I tried nbviewer (http://nbviewer.jupyter.org/). It has several options but only one of them (url) is not related to github/gist. So, in order to have an URL for my file, I uploaded it to

Tensorflow: AttributeError: 'NoneType' object has no attribute 'original_name_scope'

人走茶凉 提交于 2019-12-06 20:28:28
I am trying to run some python tensorflow code on a debian 9.5 stretch system on google cloud. I am Using tensorflow GPU version of this (the latest version) with the approriate CODA and cuDNN software installed. Here is my code: import tensorflow as tf mnist = tf.keras.datasets.mnist (x_train, y_train),(x_test, y_test) = mnist.load_data() x_train = tf.keras.utils.normalize(x_train, axis=1) # scales all values between 0 and 1 on pixel image x_test = tf.keras.utils.normalize(x_test, axis=1) model = tf.keras.models.Sequential() model.add (tf.keras.layers.Flatten()) # flattens the 28x28 pixels

How to uninstall python jupyter correctly?

↘锁芯ラ 提交于 2019-12-06 20:26:03
问题 I have jupyter installed with python3.5 on my Mac OSX , but I want the python2.7 version. So, I basically need to uninstall the 3.5 version, and reinstall the 2.7 version. But for some reason I can't uninstall the 3.5 version. I tried sudo python3 -m pip uninstall jupyter , and you can see the results below: ✔ ~/current/directory 20:08 $ which jupyter /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter ✔ ~/current/directory 20:08 $ sudo python3 -m pip uninstall jupyter The directory

How to stop bokeh from opening a new tab in Jupyter Notebook?

做~自己de王妃 提交于 2019-12-06 18:50:15
问题 First of all, before this is tagged as duplicate, I have read the other solutions and unfortunately none of them worked for me. My problem is that I want to display a bokeh plot in Juypter Notebook (and only in Jupyter Notebook), not in a new tab/window. In the official documentation here I am told that I only need to change output_file to output_notebook Even though the plot is now displayed inline if I do that, bokeh won't stop also opening a new tab and needlessly displaying the plot there