jupyter-notebook

Jupyter Notebook: Output image in previous line

岁酱吖の 提交于 2019-12-31 05:12:10
问题 I want to plot some image side by side in my jupyter notebook. So it can save some space for display. For example This is done through fig = plt.figure(figsize=(14,3)) ax1 = fig.add_subplot(1,3,1,projection = '3d') ax2 = fig.add_subplot(1,3,2) ax3 = fig.add_subplot(1,3,3) And this makes them in one .png file. However, later on in writing the paper, I may only want part of the image. For example, the 2nd or the 3rd in previous plot. And this requires me to crop the image manually . One way I

Return two data frames from a function with data frame format

≯℡__Kan透↙ 提交于 2019-12-30 19:51:28
问题 I want to return two data frames from a function, like this: def test(): df1 = pd.DataFrame([1,2,3], ['a','b','c']) df2 = pd.DataFrame([4,5,6], ['d','e','f']) return df1 return df2 test() But the function only returns one data frame df1. How to return both in pretty data frame format, not in cmd black background format? When I tried to return both using return df1, df2 in the Jupyter Notebook, the output returns the data frames in a black background cmd-like format, and not in proper data

Return two data frames from a function with data frame format

痞子三分冷 提交于 2019-12-30 19:51:07
问题 I want to return two data frames from a function, like this: def test(): df1 = pd.DataFrame([1,2,3], ['a','b','c']) df2 = pd.DataFrame([4,5,6], ['d','e','f']) return df1 return df2 test() But the function only returns one data frame df1. How to return both in pretty data frame format, not in cmd black background format? When I tried to return both using return df1, df2 in the Jupyter Notebook, the output returns the data frames in a black background cmd-like format, and not in proper data

How to run Python code before every jupyter notebook kernel

旧巷老猫 提交于 2019-12-30 18:55:00
问题 Suppose I have a code snippet that I'd like to run every time I open a jupyter notebook (in my case it's opening up a Spark connection). Let's say I save that code in a .py script: -- startup.py -- sc = "This is a spark connection" I want to be able to have that code snippet run every time I open a kernel. I've found some stuff about the Jupyter Configuration File, but it doesn't seem like variables defined there show up when I try to run print(sc) in a notebook. Is there a command-line

Using pandas to efficiently read in a large CSV file without crashing

半世苍凉 提交于 2019-12-30 10:44:26
问题 I am trying to read a .csv file called ratings.csv from http://grouplens.org/datasets/movielens/20m/ the file is 533.4MB in my computer. This is what am writing in jupyter notebook import pandas as pd ratings = pd.read_cv('./movielens/ratings.csv', sep=',') The problem from here is the kernel would break or die and ask me to restart and its keeps repeating the same. There is no any error. Please can you suggest any alternative of solving this, it is as if my computer has no capability of

Synchronizing code between jupyter/iPython notebook script and class methods

大憨熊 提交于 2019-12-30 07:06:07
问题 I'm trying to figure out the best way to keep code in an Jupyter/iPython notebook and the same code inside of a class method in sync. Here's the use case: I wrote a long script that uses pandas inside a notebook, and have multiple cells which made the development easy, because I could check intermediate results within the notebook. This is very useful with pandas scripts. I downloaded that working code into a Python ".py" file, and converted that script to be a method within a Python class in

Insert/overwrite shortcut key in Jupyter

回眸只為那壹抹淺笑 提交于 2019-12-30 05:59:42
问题 What is the Jupyter shortcut key to toggle between insert and overwrite mode whilst editing? I must keep hitting it by accident and then cannot turn off overwrite mode. I have looked at the list of shortcuts in Jupyter and online, but I could not find a match. I am working on Firefox on a Linux virtual machine running on a Mac. 回答1: Finally tracked down the problem: it was a Linux one to do with enabling Numlock. As Numlock was not turned on, the 0-key on the number keypad was acting as a

Apache Toree and Spark Scala Not Working in Jupyter

情到浓时终转凉″ 提交于 2019-12-30 04:57:06
问题 I'm having problems running Scala Spark on Jupyter. Below is my error message when I load Apache Toree - Scala notebook in jupyter. root@ubuntu-2gb-sgp1-01:~# jupyter notebook --ip 0.0.0.0 --port 8888 [I 03:14:54.281 NotebookApp] Serving notebooks from local directory: /root [I 03:14:54.281 NotebookApp] 0 active kernels [I 03:14:54.281 NotebookApp] The Jupyter Notebook is running at: http://0.0.0.0:8888/ [I 03:14:54.281 NotebookApp] Use Control-C to stop this server and shut down all kernels

Change the Theme in Jupyter Notebook?

二次信任 提交于 2019-12-29 10:08:30
问题 I like dark themes. However, the default theme of Jupyter notebooks is light, and I can't find the option to change the theme/background-color. How is this done? 回答1: This is easy to do using the jupyter-themes package by Kyle Dunovan. You may be able to install it using conda . Otherwise, you will need to use pip . Install it with conda: conda install jupyterthemes or pip pip install jupyterthemes Then change your theme with jt -t chesterish To load the chesterish theme or any other. Finally

Change the Theme in Jupyter Notebook?

扶醉桌前 提交于 2019-12-29 10:08:10
问题 I like dark themes. However, the default theme of Jupyter notebooks is light, and I can't find the option to change the theme/background-color. How is this done? 回答1: This is easy to do using the jupyter-themes package by Kyle Dunovan. You may be able to install it using conda . Otherwise, you will need to use pip . Install it with conda: conda install jupyterthemes or pip pip install jupyterthemes Then change your theme with jt -t chesterish To load the chesterish theme or any other. Finally