ipython

ipython pandas TypeError: read_csv() got an unexpected keyword argument 'delim-whitespace''

ぐ巨炮叔叔 提交于 2019-12-11 02:22:15
问题 While trying the ipython.org notebook, "INTRODUCTION TO PYTHON FOR DATA MINING" The following code: data = pd.read_csv("http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data-original", delim_whitespace = True, header=None, names = ['mpg', 'cylinders', 'displacement', 'horsepower', 'weight', 'acceleration', 'model', 'origin', 'car_name']) yields the following error: TypeError: read_csv() got an unexpected keyword argument 'delim-whitespace' Unfortunately the dataset

KeyboardInterrupt unpredictable in Python 2.7 under ipython, how can I make it *always* abort current evaluation?

不问归期 提交于 2019-12-11 02:21:24
问题 I'm writing python code to do numerical analysis, and I've been using ipython or ipython -pylab as my command line interface. I often run into situations where some code is taking for-freaking-ever to run, and I need to stop it. However, Ctrl-C is problematic; sometimes it works, sometimes it doesn't do anything, and sometimes it quits the whole process ( very annoying.) How can I make it so that hitting Ctrl-C always always works? It seems as if the times that it doesn't work are those where

Strange accuracy difference between ipython and ipython notebook then using fortran module with f2py

試著忘記壹切 提交于 2019-12-11 02:15:19
问题 I'm encountering a strange accuracy difference between ipython and the ipython notebook when using a fortran module compiled with f2py. My fortran module is: subroutine tt(string,fmt,n_num,out) implicit none INTEGER,INTENT(IN)::n_num CHARACTER(LEN=*),INTENT(IN)::string CHARACTER(LEN=*),INTENT(IN)::fmt DOUBLE PRECISION,INTENT(OUT)::out(n_num) read(string,fmt) out end subroutine tt Compiling with: f2py -c -m andre tt.f90 In ipython i get: In [1]: import numpy as np In [2]: import andre In [3]:

how to get intermidiate results in ipython parallel processing?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 02:13:06
问题 my work is to deal with lots of xmls; to get faster results i want to use ipython's parallel processing; below is my sample code. in that i am just finding the number of elements of xml/xsd with celementTree module. >>> from IPython.parallel import Client >>> import os >>> c = Client() >>> c.ids >>> lview = c.load_balanced_view() >>> lview.block =True >>> def return_len(xml_filepath): import xml.etree.cElementTree as cElementTree tree = cElementTree.parse(xml_filepath) my_count=0 file_result=

Returning semi-unique values from a list

蓝咒 提交于 2019-12-11 02:08:36
问题 Not sure how else to word this, but say I have a list containing the following sequence: [a,a,a,b,b,b,a,a,a] and I would like to return: [a,b,a] How would one do this in principle? 回答1: You can use itertools.groupby , this groups consecutive same elements in the same group and return an iterator of key value pairs where the key is the unique element you are looking for: from itertools import groupby [k for k, _ in groupby(lst)] # ['a', 'b', 'a'] lst = ['a','a','a','b','b','b','a','a','a'] 回答2

Can Jupyter run a separate R notebook from within a Python notebook?

ぐ巨炮叔叔 提交于 2019-12-11 02:04:52
问题 I have a Jupyter notebook (python3) which is a batch job -- it runs three separate python3 notebooks using %run . I want to invoke a fourth Jupyter R-kernel notebook from my batch. Is there a way to execute an external R notebook from a Python notebook in Jupyter / iPython? Current setup: run_all.ipynb : (python3 kernel) %run '1_py3.ipynb' %run '2_py3.ipynb' %run '3_py3.ipynb' %run '4_R.ipynb' The three python3 notebooks run correctly. The R notebook runs correctly when opened separately in

Jupyter Notebook: Change Data Rate Limit Inside Active Notebook

匆匆过客 提交于 2019-12-11 01:48:19
问题 I have a jupyter notebook where an executed cell gives the following error: IOPub data rate exceeded... I understand this is an option: jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10 However, I would really prefer to just to set this along with my import statements and other notebook settings instead of tweaking configuration files or command line when starting notebooks. Is there an easy way to do this? 回答1: I would recommend creating an alias jn to launch Jupyter notebook with

IPython notebook - unable to export to pdf

风流意气都作罢 提交于 2019-12-11 01:04:51
问题 I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0. Thank you in advance :) 回答1: Convert the IPython notebook file to html. ipython nbconvert --to html notebook.ipynb This will convert the IPython document file notebook.ipynb

Ipython raw_input work around?

拥有回忆 提交于 2019-12-11 00:52:46
问题 I'm running a Python program that wants to accept raw_input which Ipython notebook does not do. (a known limitation) What is a recommended way to achieve the functionality? (work around?) What I'd like to do is to be able to run the program, accept input and respond..(will be choices determined based on information retrieved), and also prompting for user id and password info.. Of course I'd like to do as little violence to the existing code as possible. I found IPython.utils.io.raw_input_ext

Import from ipython

狂风中的少年 提交于 2019-12-11 00:47:36
问题 If I use IDLE with python 2.7 import cv import cv2 and it works but if I use ipython notebook it gives me error ImportError Traceback (most recent call last) in () ----> 1 import cv ImportError: No module named cv So how to use OpenCV from iPython? EDIT: from IDLE ['', 'C:\Python27\Lib\idlelib', 'C:\Python27\lib\site-packages\pip-1.1-py2.7.egg', 'C:\Python27\lib\site-packages\gensim-0.8.6-py2.7.egg', 'C:\WINDOWS\system32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib