Running a small pandas sample in IPython

Now that Python and pandas is installed, let's write our first pandas application. We will write it in the IPython interpreter. IPython is an alternative shell for executing Python applications, and it conveniently provides numeric sequence numbers for thin input and output for example purposes. This is convenient for matching specific code examples in the book and will be used in all examples.

Note

IPython or IPython Notebooks will be the tools for all remaining examples in the book.

IPython is started using the ipython command from the shell or command line:

Michaels-MacBook-Pro:~ michaelheydt$ ipython
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46) 
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
?         -> 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]:

IPython is now ready to accept your programming statements. Enter the following three lines of code:

import pandas as pd
df = pd.DataFrame.from_items([('column1', [1, 2, 3])])
print (df)

When completed, you should have the following output in the IPython console:

In [1]: import pandas as pd

In [2]: df = pd.DataFrame.from_items([('column1', [1, 2, 3])])

In [3]: print (df)
   column1
0        1
1        2
2        3

In [4]:

Congratulations, you have created your first pandas application!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.254.61