jupyter-notebook

ImportError: No module named numpy - Google Cloud Dataproc when using Jupyter Notebook

一世执手 提交于 2019-12-22 10:36:42
问题 When starting Jupyter Notebook on Google Dataproc, importing modules fails. I have tried to install the modules using different commands. Some examples: import os os.sytem("sudo apt-get install python-numpy") os.system("sudo pip install numpy") #after having installed pip os.system("sudo pip install python-numpy") #after having installed pip import numpy None of the above examples work and return an import error: enter image description here When using command line I am able to install

iPython- Is there a way to answer “y” to (or ignore) all y/n prompts?

夙愿已清 提交于 2019-12-22 10:36:28
问题 So I have an ipython notebook that has a lot of large variables, and at one point I want to get rid of all the ones I'm done with. I'm using %reset_selective variablename to clear each one, but there's 60 of these variables and when I run the block that has all 60 prompts, it asks me to enter y/n for every clear. "Once deleted, variables cannot be recovered. Proceed (y/[n])?" Is there a way I can answer "y" for all of them at once, or to skip the prompt altogether? 回答1: Reading from here:

Read multiple CSV files in Pandas in chunks

删除回忆录丶 提交于 2019-12-22 10:29:28
问题 How to import and read multiple CSV in chunks when we have multiple csv files and total size of all csv is around 20gb? I don't want to use Spark as i want to use a model in SkLearn so I want the solution in Pandas itself. My code is: allFiles = glob.glob(os.path.join(path, "*.csv")) df = pd.concat((pd.read_csv(f,sep=",") for f in allFiles)) df.reset_index(drop=True, inplace=True) But this is failing as the total size of all the csv in my path is 17gb. I want to read it in chunks but I

interact and plotting with ipywidgets events produces many graphs

孤者浪人 提交于 2019-12-22 10:16:04
问题 I am trying to use widget events to make an interactive graph. %matplotlib inline import numpy as np import matplotlib.pyplot as plt import ipywidgets as widgets def myplot(n): x = np.linspace(-5, 5, 30) y = x**n fig, ax = plt.subplots(nrows=1, ncols=1); ax.plot(x, y) ax.set_xlabel('x') ax.set_ylabel('y') plt.show() Interact works as expected (it changes the figure interactively): widgets.interact(myplot, n=(0,5)); However the following snippet creates several figures that appear below as you

How to change multiple interactive plots with a single input in Python

亡梦爱人 提交于 2019-12-22 09:35:50
问题 I am trying to make several interactive plots with the ipywidgets library in Jupyter Notebook. I face however one problem: I try to make multiple plots change when one single input widget changes, for example a slider. In the added MWE this is illustrated with a sine and cosine function that both depend on a single input widget that sets the amplitude of both the sine and the cosine function. Thus, if the value of the input slider is set at the value 2, the amplitude of both the sine and

ImportError: No module named IPython.paths when running jupyter notebook?

亡梦爱人 提交于 2019-12-22 08:42:20
问题 I installed jupyter via: /usr/local/opt/python/bin/python2.7 -m pip install jupyter this install ipython version 4.1.2. However, when I run jupyter notebook, I get: Traceback (most recent call last): File "/usr/local/bin/jupyter-notebook", line 7, in <module> from notebook.notebookapp import main File "/Library/Python/2.7/site-packages/notebook/notebookapp.py", line 83, in <module> from IPython.paths import get_ipython_dir ImportError: No module named IPython.paths yet, when I run from

How to insert a literal tab instead of auto-completing in Jupyter?

时光毁灭记忆、已成空白 提交于 2019-12-22 08:13:14
问题 It is easy to indent a whole line. Just highlight the whole line and press Tab Go to the start of the line and press Tab Click anywhere in the line and press Ctrl + ] Now the problem is how to insert indent in the middle of the line. And also, how to indent at the end of the line. Example usage scenario: # Hyperparameters LENGTH = 10 # length of foo TEMP = 20 # temperature of bar IV = 99.99 # induction variability of foo bar Concretely, we want: # Hyperparameters LENGTH = 10 # length of foo

r graphs in jupyter - unable to start png() device

折月煮酒 提交于 2019-12-22 08:10:03
问题 I am using R in Jupyter, but unable to plot graphs in the notebook itself. Here is a reproducible example set.seed(123) mat = as.matrix(x = rnorm(100), y = rnorm(100)) plot(mat) In Jupyter: Error in png(tf, width, height, "in", pointsize, bg, res, antialias = antialias): unable to start png() device Traceback: If I use following, I can save the image in png format in current working directory. png('test.png') plot(mat) dev.off() Edit: SessionInfo() R version 3.4.4 (2018-03-15) Platform: x86

How to pass command line arguments in IPython jupyter notebook

白昼怎懂夜的黑 提交于 2019-12-22 08:03:42
问题 I a new to Ipython. Currently i have installed Ipython using Anaconda and writing a code to plot chart using jupyter notebook UI. I want to pass few arguments to my working script with the help of argparse module. below is the code.. import argparse parser = argparse.ArgumentParser(description = 'Process display arguments') parser.add_argument('-t', "--test_name", help="Mandatory test name directory path", type=str) parser.add_argument('-s', "--symbolSet", nargs = '?', help="Optional

How to execute a single line or selected code in a Jupyter Notebook or JupyterLab cell?

…衆ロ難τιáo~ 提交于 2019-12-22 07:52:13
问题 In both JupyterLab and Jupyter Notebook you can execute a cell using ctrl + Enter : Code: print('line 1') print('line 2') print('line 3') Cell and output: But how can you run only line 2 ? Or even a selection of lines within a cell without running the entire cell? Sure you could just insert a cell with that single line or selection of lines, but that gets really cumbersome and messy really quick. So are there better ways of doing this? 回答1: Short answer: Jupyter notebook: qtconsole scratchpad