ipython-notebook

Cannot import .py file to ipython notebook

早过忘川 提交于 2019-12-18 06:56:44
问题 With apologies in advance for the "I can't get it to work" question: How should I load a .py file into ipython notebook? I want to convert python code to notebooks (first simple scripts and later scripts that include nbconvert directives embedded as comments-- see bottom of the linked file.) Perhaps I'm doing it wrong, but perhaps there's something wrong with my set-up. When I drag a .py file to the Notebook's file list, I get the message Invalid file type: Uploaded notebooks must be .ipynb

Jupyter: can't create new notebook?

故事扮演 提交于 2019-12-18 03:04:29
问题 I have some existing Python code that I want to convert to a Jupyter notebook. I have run: jupyter notebook Now I can see this in my browser: But how do I create a new notebook? The Notebook link in the menu is greyed out, and I can't see any other options to create a new notebook. I've noticed this on the command line while Jupyter is running: [W 22:30:08.128 NotebookApp] Native kernel (python2) is not available 回答1: It looks like you don't have an IPython kernel installed (or any other

Reusing code from different IPython notebooks

冷暖自知 提交于 2019-12-17 22:12:56
问题 I am using IPython and want to run functions from one notebook from another (without cutting and pasting them between different notebooks). Is this possible and reasonably easy to do? 回答1: You can connect with a qtconsole to the same kernel. Just supply this at startup: ipython qtconsole --existing kernel-0300435c-3d07-4bb6-abda-8952e663ddb7.json Look at the output after starting the notebook for the long string. 回答2: Starting your notebook server with: ipython notebook --script will save the

Download CSV from an iPython Notebook

穿精又带淫゛_ 提交于 2019-12-17 18:48:30
问题 I run an iPython Notebook server, and would like users to be able to download a pandas dataframe as a csv file so that they can use it in their own environment. There's no personal data, so if the solution involves writing the file at the server (which I can do) and then downloading that file, I'd be happy with that. 回答1: How about using the FileLinks class from IPython? I use this to provide access to data directly from Jupyter notebooks. Assuming your data is in pandas dataframe p_df: from

Simple way to choose which cells to run in ipython notebook during run all

▼魔方 西西 提交于 2019-12-17 18:24:48
问题 I have an ipython notebook that runs several steps in a data processing routine and saves information in files along the way. This way, while developing my code (mostly in a separate .py module), I can skip to and run various steps. I'd like to set it up so that I can Cell -> run all but only have it execute certain chosen steps that would be easily chosen. e.g., I'd envision defining the steps I want to run in a dict like so: process = { 'load files':False, 'generate interactions list':False

ipython notebook --script deprecated. How to replace with post save hook?

回眸只為那壹抹淺笑 提交于 2019-12-17 18:18:37
问题 I have been using "ipython --script" to automatically save a .py file for each ipython notebook so I can use it to import classes into other notebooks. But this recenty stopped working, and I get the following error message: `--script` is deprecated. You can trigger nbconvert via pre- or post-save hooks: ContentsManager.pre_save_hook FileContentsManager.post_save_hook A post-save hook has been registered that calls: ipython nbconvert --to script [notebook] which behaves similarly to `--script

ipython notebook clear cell output in code

你。 提交于 2019-12-17 15:10:23
问题 In a iPython notebook, I have a while loop that listens to a Serial port and print the received data in real time. What I want to achieve to only show the latest received data (i.e only one line showing the most recent data. no scrolling in the cell output area) What I need(i think) is to clear the old cell output when I receives new data, and then prints the new data. I am wondering how can I clear old data programmatically ? 回答1: You can use IPython.display.clear_output to clear the output

Jupyter notebook display two pandas tables side by side

放肆的年华 提交于 2019-12-17 15:04:59
问题 I have two pandas dataframes and I would like to display them in Jupyter notebook. Doing something like: display(df1) display(df2) Shows them one below another: I would like to have a second dataframe on the right of the first one. There is a similar question, but it looks like there a person is satisfied either with merging them in one dataframe of showing the difference between them. This will not work for me. In my case dataframes can represent completely different (non-comparable elements

PySpark in iPython notebook raises Py4JJavaError when using count() and first()

牧云@^-^@ 提交于 2019-12-17 11:44:35
问题 I am using PySpark(v.2.1.0) in iPython notebook (python v.3.6) over virtualenv in my Mac(Sierra 10.12.3 Beta). 1.I launched iPython notebook by shooting this in Terminal - PYSPARK_PYTHON=python3 PYSPARK_DRIVER_PYTHON=ipython PYSPARK_DRIVER_PYTHON_OPTS="notebook" /Applications/spark-2.1.0-bin-hadoop2.7/bin/pyspark 2.Loaded my file to Spark Context and ensured its loaded- >>>lines = sc.textFile("/Users/PanchusMac/Dropbox/Learn_py/Virtual_Env/pyspark/README.md") >>>for i in lines.collect():

How to change font in ipython notebook

本小妞迷上赌 提交于 2019-12-17 10:22:42
问题 I am fairly new to python and have no html experience. The question has been asked and either not answered at all or not answered in enough detail for me to set the default font within iPython (not change to browser). Specifically, what has to be put in the css file and which css file should be used? I am on a Windows system. For reference, these are in answer to the linked SO questions below: in #1: an unnamed file in /usr/lib/python2.6/.../css/ in comment to #1: change monospace font in