ipython

Ipython Numpy pandas

守給你的承諾、 提交于 2019-12-24 19:53:51
Ipython:交互式的Python命令行 TAB:自动完成 ?:内省,命令空间搜索 !:执行系统命令 %run:命令执行文件代码 Ipython常用魔术命令: %quickref:显示Ipython的快速参考 %magic:显示所有魔术命令的详细文档 %debug:从最新的异常追踪的底部进入交互式命令调试器 %hist:打印命令的输入(可选输出)历史 %pdb:在异常发生后自动进入调试器 %paste:执行剪贴板中的Python代码 %cpaste:打开一个特殊提示符以便手工粘贴待执行的Python代码 %reset:删除interactive命名空间中的全部变量/名称 %page OBJECT:通过分页器打印输出OBJECT %run script.py:在Ipython中执行一个Python脚本文件 %prun statement:通过cProfile执行statement,并打印分析器的输出结果 %time statement:报告statement的执行时间 %timeit statement:多次执行statement以计算系统平均执行时间,对那些执行时间非常小的代码有用 %who %who_is %whos:显示interactive命名空间中定义的变量,信息级别/冗余度可变 %xdel variable:删除variable

error with IPython in showing plots with pyqtgraph

Deadly 提交于 2019-12-24 17:27:29
问题 i have successfully installed pyqtgraph library in python 2.7. I forked latest project from GitHub and then python setup.py install . I am now trying to show plots with it. I open a python terminal and start typing the following:- import pyqtgraph as pg import numpy as np x = np.random.normal(size=1000) y = np.random.normal(size=1000) All of these commands are successfully interpreted. But then i run the command to see the plot as:- pg.plot(x, y, symbol='o') It outputs: <pyqtgraph

How can i make ipythons RichIPythonWidget use pyside in a pyinstaller environment?

匆匆过客 提交于 2019-12-24 17:19:23
问题 I have an application that i build using pyinstaller, and it uses PySide for its Qt Gui. I included an interactive prompt by embedding an ipython qtconsole. This breaks the builds created by pyinstaller. Here is a minimal (non-)working example: from PySide.QtGui import * from IPython.qt.console.rich_ipython_widget import RichIPythonWidget from IPython.qt.inprocess import QtInProcessKernelManager from IPython.lib import guisupport class IPythonWidget(RichIPythonWidget): def __init__(self,

Fail to import IPython parallel in Jupyter

故事扮演 提交于 2019-12-24 17:19:21
问题 I recently made an update of IPython to 4.0.0 and installed Jupyter 4.0.6. I wanted to use Ipython parallel, and after starting the engines in the notebook, I imported: from IPython import parallel And it fails: ~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package. warn("IPython.utils.traitlets has moved to a top-level traitlets package.") ~/Library/Enthought/Canopy_64bit

matplotlib.pyplot contourf function introduces holes or gaps when plotting regular data

柔情痞子 提交于 2019-12-24 17:14:41
问题 I am trying to plot a 3D dataset using the contourf function in matplotlib.pyplot. All of this is being run inside an iPython notebook. A surface plot of the data looks fine, but the contourf plot has a big hole in it. A simplified version of the code I am using is: import numpy as np # import modules import scipy.io as spio import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(figsize=(12,5)) zMin = 1.2 data = spio.loadmat('./OD_SurfMatFiles/surf_k2_c3.mat'

maximum of a function on a specified domain in iPython

╄→尐↘猪︶ㄣ 提交于 2019-12-24 16:57:02
问题 I am trying to find the maximum of the following function for 1 < R < 20. How can I implement this into the code? The solution is supposed to be R is approx 15.5 or so. #!/usr/bin/env python # Plotting the energy for circular Hohmann transfer import scipy import matplotlib import numpy as np import pylab def f(R): return 1 / np.sqrt(R) - (np.sqrt(2) * (1 - R)) / (np.sqrt(2) * (1 + R)) - 1 x = np.arange(1, 20) pylab.plot(x, f(x), 'r') pylab.show() 回答1: You can use scipy.optimizie.fmin : >>>

Using ipcluster to connect to an OS X server w/ EPD from Linux?

家住魔仙堡 提交于 2019-12-24 16:23:07
问题 I am trying to use IPython.parallel's support for SSH to allow my Linux client to run remote ipengine s from an OS X server that has EPD64 installed. This fails, however, as it attempts to use my local machine to figure out the right command to run on the remote host, which has its ipengineapp package in a different location. How do I modify ipcluster_config.py to recognize the difference? Concretely, when I run ipcluster start --log-level=DEBUG on the remote host, I get console output

Pandas: inserting rows of even number years

£可爱£侵袭症+ 提交于 2019-12-24 16:09:35
问题 I have the following abridged dataframe: df1 = pd.DataFrame({'end': [2007, 2013, 2014, 2013, 2014], 'id.thomas'\ : ['136', '136', '136', '172', '172'], 'years_exp': ['14', '20', '21', \ '14', '15']}, index=[2,3,4,5,6]) end id.thomas years_exp 2 2007 136 14 3 2013 136 20 4 2014 136 21 5 2013 172 14 6 2014 172 15 where end is representative of years. I would like to expand the end and years_exp column to account account for the missing years: end id.thomas years_exp 2 2007 136 14 3 2008 136 15

how to get on hover animation of pygal graphs in ipython on mac osx

怎甘沉沦 提交于 2019-12-24 14:36:05
问题 I have just started using pygal in ipython after installing CairoSVG with pip and Cairo with homebrew. The graphs render but when I hover over them there is no interactivity (displaying the frequency for a single bar on a bar graph for example)? What do I need to install to achieve the same rollover/hover functionality that can be seen in the Pygal Documentation? http://www.pygal.org/en/latest/documentation/first_steps.html For example when you click on a legend item on a graph, the legend

IPython notebook: How to write cell magic which can access notebook variables?

天涯浪子 提交于 2019-12-24 14:15:07
问题 My question is: How can I write an IPython cell magic which has access to the namespace of the IPython notebook? IPython allows writing user-defined cell magics. My plan is creating a plotting function which can plot one or multiple arbitrary Python expressions (expressions based on Pandas Series objects), whereby each line in the cell string is a separate graph in the chart. This is the code of the cell magic: def p(line, cell): import pandas as pd import matplotlib.pyplot as plt df = pd