jupyter-notebook

Are unicode identifiers in python bad practice?

旧城冷巷雨未停 提交于 2019-12-10 10:58:24
问题 I am getting into machine learning, and to document my code, I will write LaTeX math versions of my functions, right next to the code in an Jupyter/IPython notebook. The mathematical definitions include many Greek symbols, so I thought that I might as well use the Greek symbols in function and variable names, since that's possible in python. Would this be bad practice? 回答1: It seems a good use case under these assumptions: the audience is mathematically versed, you make use of a lot of

Awk print with pipes not working iPython in Jupyter Notebook

我的梦境 提交于 2019-12-10 10:54:55
问题 So the command below does not give me any output in Jupyter Notebook with iPython: IP = '62.172.72.131' !cat hits.csv | grep {IP} | awk '{print $1}' I have tried both double and single "$" sign and none of them works. If I only use one pipe in the command, it works fine. For example: IP = '62.172.72.131' !cat hits.csv | grep {IP} !cat hits.csv | awk '{print $1}' Anyone know why this is happening? Thanks! 回答1: I think I figured this out. The "$" and "{" and "}" are all special characters in

Messaging and Jupyter Notebooks

ぃ、小莉子 提交于 2019-12-10 10:46:27
问题 I'm trying to wrap my head around messaging in Jupyter notebooks. But I'm a bit lost and confused. My goal is fairly straight forward to state: I want my python kernel to update the output of a cell in a Jupyter notebook while a long calculation is running. Whenever new data arrives in the browser, I want to trigger a redraw by calling some javascript function. Specifically, the cell output contains HTML with a WebGL canvas. That part works well. I can easily visualize the initial data in the

Jupyter Notebook Set Default Folder to Root

人走茶凉 提交于 2019-12-10 10:26:59
问题 I am using Jupyter Notebook on Windows 7, and I want to set the default foler to D: . Currently, I have the following line in my jupyter_notebook_config.py: c.NotebookApp.notebook_dir = 'D:/' When I open Jupyter Notebook, in the browser I receive the following message: 404 : Not Found You are requesting a page that does not exist! In the prompt, I get the following output: [W 14:12:45.477 NotebookApp] ipywidgets package not installed. Widgets are unavailable. [I 14:12:45.497 NotebookApp]

Execute algorithm step by step in Jupyter

我的梦境 提交于 2019-12-10 10:06:07
问题 I am trying to show the execution of a Python program in Jupyter, step by step. For example, I can visualize the value of a variable in a program as in the following toy program: from IPython.display import display, clear_output from time import sleep def sum_first_integers(n): res = 0 for i in range(n+1): res += i clear_output(wait=True) display(res) sleep(.5) return res This shows the value of res at each step of the algorithm, and I added a sleep(.5) to be able to actually view the

How to display plotly outputs in google collaboratory notebooks?

隐身守侯 提交于 2019-12-10 09:33:42
问题 I searched whole day how to display the outputs of plotly plots in google colaboratory jupyter notebooks. There is a stackoverflow question and also official tutorial from google colaboratory but both of them did not work for me. official link: https://colab.research.google.com/notebooks/charts.ipynb#scrollTo=hFCg8XrdO4xj stackoverflow question: Plotly notebook mode with google colaboratory https://colab.research.google.com/drive/14oudHx5e5r7hm1QcbZ24FVHXgVPD0k8f#scrollTo=8RCjUVpi2_xd The

Google colab file download failed to fetch error

橙三吉。 提交于 2019-12-10 09:32:27
问题 I used google colab to make a dictionary, dump it into a json file and download the file into my laptop by this code: from google.colab import files import json dict = {'apple': 'fruit', 'mango': 'fruit', 'carrot': 'vegetable', 'brocoli': 'vegetable', 'cat': 'animal'} with open('sampleDictionary.json', 'w') as f: json.dump(dict, f) files.download('sampleDictionary.json') f.close() When I try to run this code, it gives this error: MessageError Traceback (most recent call last) <ipython-input

Pyspark - converting json string to DataFrame

吃可爱长大的小学妹 提交于 2019-12-10 05:45:11
问题 I have a test2.json file that contains simple json: { "Name": "something", "Url": "https://stackoverflow.com", "Author": "jangcy", "BlogEntries": 100, "Caller": "jangcy"} I have uploaded my file to blob storage and I create a DataFrame from it: df = spark.read.json("/example/data/test2.json") then I can see it without any problems: df.show() +------+-----------+------+---------+--------------------+ |Author|BlogEntries|Caller| Name| Url| +------+-----------+------+---------+------------------

How to suppress matplotlib inline for a single cell in Jupyter Notebooks/Lab?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 05:13:19
问题 I was looking at matplotlib python inline on/off and this kind of solves the problem but when I do plt.ion() all of the Figures pop up (100s of figures). I want to keep them suppressed in a single cell. Is there a with loop I can use to turn off %matplotlib inline or is this impossible? 来源: https://stackoverflow.com/questions/49545003/how-to-suppress-matplotlib-inline-for-a-single-cell-in-jupyter-notebooks-lab

Setting a default sys.path for a Notebook

早过忘川 提交于 2019-12-10 03:34:20
问题 I have all my .py files inside a folder script and all my IPython-notebooks under a folder named Notebook. There are multiple cross dependencies for each notebook file on one or more files on script. Having sys.path.append on top of every notebook seems cumbersome and I am hoping there is a way to add a default lookup path just like we add PYTHONPATH to .bash_profile . Now I do the following: import sys sys.path.append("<path where DeriveFinalResultSet.py exists>) import DeriveFinalResultSet