Python for Finance: Analyze Big Financial Data

(Elle) #1
$   ipython
Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Feb 10 2014, 17:56:29)
Type “copyright”, “credits” or “license” for more information.

IPython 2.0.0   —   An  enhanced    Interactive Python.
? -> Introduction and overview of IPython’s features.
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.
In [ 1 ]: 3 + 4 * 2
Out[1]: 11
In [ 2 ]:

Using the option —pylab imports a large set of scientific and data analysis libraries, like


NumPy, in the namespace:


$   ipython —pylab
Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Feb 10 2014, 17:56:29)
Type “copyright”, “credits” or “license” for more information.

IPython 2.0.0   —   An  enhanced    Interactive Python.
? -> Introduction and overview of IPython’s features.
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.
Using matplotlib backend: MacOSX
In [ 1 ]: a = linspace( 0 , 20 , 5 ) # linspace from NumPy

In  [ 2 ]:  a

Out[ 2 ]:   array([     0.,         5.,     10.,        15.,        20.])

In  [ 3 ]:

Similarly, the QT console of IPython is invoked by the following command:


$   ipython qtconsole   —pylab  inline

Using the inline parameter in addition to the —pylab option lets IPython plot all graphics


inline. Figure 2-2 shows a screenshot of the QT console with an inline plot.


Finally, the Notebook version is invoked as follows:


$   ipython notebook    —pylab  inline

Figure 2-3 shows a screenshot of an IPython Notebook session. The inline option again


has the effect that plots will be displayed in IPython Notebook and not in a separate


window.


All in all, there are a large number of options for how to invoke an IPython kernel. You


can get a listing of all the options by typing:


$   ipython —h

Refer to the IPython documentation for detailed explanations.

Free download pdf