Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning Pandas
Learning Pandas

Learning Pandas: Get to grips with pandas - a versatile and high-performance Python library for data manipulation, analysis, and discovery

eBook
€35.98 €39.99
Paperback
€49.99
Hardcover
€41.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learning Pandas

Chapter 2. Installing pandas

In this chapter, we will cover how to install pandas using the Anaconda Scientific Python distribution from Continuum Analytics. Anaconda is a popular Python distribution with both free and paid components, and it has cross-platform support—including Windows, Mac, and Linux. The base distribution installs pandas as part of the default installation, so it makes getting started with pandas simple.

The chapter will examine installing both pandas and Python through Anaconda, as this book assumes that you are new to both pandas and Python. This can include readers who are coming from an R environment to learn data manipulation skills using pandas. Those who already have more advanced Python skills can feel free to move onto later chapters or use alternative Python distributions and package managers, as well as virtualized development environments for multiple Python distributions.

In general, the remaining chapters of this book will focus on data manipulation...

Getting Anaconda

We will focus on installing Anaconda Python and ensuring that pandas is up to date within that distribution. You are not limited to using pandas with Anaconda, as pandas is supported by most Python distributions—although the specific installation tasks on each distribution may differ from those covered in this chapter. If you use another Python distribution, feel free to use your package manager of choice or pip from PyPI.

Note

I would say most Python distributions because—being a Mac user—I've found it very difficult (if not impossible) to install pandas into the default Python provided in OS X by Apple.

At the time of writing, pandas is at Version 0.15.1. The current version of Anaconda is 2.1.9 that contains Python 2.7.8, but comes with pandas 0.14.1 by default. Therefore, we will update to v0.15.1 using the conda package manager provided by Anaconda.

Anaconda Python can be downloaded from the Continuum Analytics website at http://continuum.io...

Installing Anaconda

The installation of Anaconda is straightforward, but varies slightly by platform. We will cover the installation of Anaconda on Linux, Mac, and Windows platforms. After this installation, pandas will likely need to be updated, which is an identical process across platforms using the conda package manager.

Installing Anaconda on Linux

The download will place a shell script/installer on your system (the following shell script/installer assumes to be downloaded to the ~/Download folder). The name of the file will differ depending upon the Anaconda version and the architecture of Linux selected. This example is using Ubuntu 13.10, AMD64 platform and Anaconda Version 2.1.0. The file downloaded in this scenario is Anaconda-2.1.0-Linux-x86_64.sh.

Once downloaded, make the script executable and run it with the following command:

mh@ubuntu:~/Downloads$ chmod +x Anaconda-2.1.0-Linux-x86_64.sh
mh@ubuntu:~/Downloads$ ./Anaconda-2.1.0-Linux-x86_64.sh

The script will execute and you will...

Ensuring pandas is up to date

Now that Anaconda is installed, we can check the version of pandas that is installed either from within the Python interpreter or from the command line. The means to perform both of these is the same on each platform, and this will be demonstrated from an OS X terminal.

From within the Anaconda Python interpreter, you can check the version of pandas on the system by importing pandas and then examining the version with the following two Python statements:

>>>import pandas as pd
>>>print (pd.__version__)

The preceding commands will then report the version of pandas. The following screenshot shows that v0.14.1 is the currently installed version:

Ensuring pandas is up to date

This has reported that pandas version is 0.14.1, which is not the most recent, so we may want to update.

You can also check the pandas version using the conda package manager from the command line as follows (which also reports that version is 0.14.1):

Michaels-MacBook-Pro:~ michaelheydt$ conda list pandas...

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
?         ...

Starting the IPython Notebook server

IPython Notebooks are a web server-based interactive environment that combine Python code execution, text, mathematics, plots, and rich media into a single document, along with automatic persistence of code and an easy means of deploying code to the Web. You can find more details on the IPython Notebook site at http://ipython.org/notebook.html.

IPython Notebooks are an exceptional way to learn both Python and pandas. This book will neither assume the use of IPython Notebooks, nor teach their usage beyond the brief examples given in this section. However, the code provided with the book are IPython Notebook files, so demonstrating how to run the server provided by Anaconda is worth a few paragraphs of explanation.

The IPython Notebook server can be started with the following shell command (the same on all platforms):

ipython notebook

You will get a small amount of output on the console:

elheydt/.ipython/profile_default'
2014-12-06 21:36:11.547 [NotebookApp...

Getting Anaconda


We will focus on installing Anaconda Python and ensuring that pandas is up to date within that distribution. You are not limited to using pandas with Anaconda, as pandas is supported by most Python distributions—although the specific installation tasks on each distribution may differ from those covered in this chapter. If you use another Python distribution, feel free to use your package manager of choice or pip from PyPI.

Note

I would say most Python distributions because—being a Mac user—I've found it very difficult (if not impossible) to install pandas into the default Python provided in OS X by Apple.

At the time of writing, pandas is at Version 0.15.1. The current version of Anaconda is 2.1.9 that contains Python 2.7.8, but comes with pandas 0.14.1 by default. Therefore, we will update to v0.15.1 using the conda package manager provided by Anaconda.

Anaconda Python can be downloaded from the Continuum Analytics website at http://continuum.io/downloads. The web server will...

Installing Anaconda


The installation of Anaconda is straightforward, but varies slightly by platform. We will cover the installation of Anaconda on Linux, Mac, and Windows platforms. After this installation, pandas will likely need to be updated, which is an identical process across platforms using the conda package manager.

Installing Anaconda on Linux

The download will place a shell script/installer on your system (the following shell script/installer assumes to be downloaded to the ~/Download folder). The name of the file will differ depending upon the Anaconda version and the architecture of Linux selected. This example is using Ubuntu 13.10, AMD64 platform and Anaconda Version 2.1.0. The file downloaded in this scenario is Anaconda-2.1.0-Linux-x86_64.sh.

Once downloaded, make the script executable and run it with the following command:

mh@ubuntu:~/Downloads$ chmod +x Anaconda-2.1.0-Linux-x86_64.sh
mh@ubuntu:~/Downloads$ ./Anaconda-2.1.0-Linux-x86_64.sh

The script will execute and you will...

Ensuring pandas is up to date


Now that Anaconda is installed, we can check the version of pandas that is installed either from within the Python interpreter or from the command line. The means to perform both of these is the same on each platform, and this will be demonstrated from an OS X terminal.

From within the Anaconda Python interpreter, you can check the version of pandas on the system by importing pandas and then examining the version with the following two Python statements:

>>>import pandas as pd
>>>print (pd.__version__)

The preceding commands will then report the version of pandas. The following screenshot shows that v0.14.1 is the currently installed version:

This has reported that pandas version is 0.14.1, which is not the most recent, so we may want to update.

You can also check the pandas version using the conda package manager from the command line as follows (which also reports that version is 0.14.1):

Michaels-MacBook-Pro:~ michaelheydt$ conda list pandas...
Left arrow icon Right arrow icon

Description

If you are a Python programmer who wants to get started with performing data analysis using pandas and Python, this is the book for you. Some experience with statistical analysis would be helpful but is not mandatory.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 16, 2015
Length: 504 pages
Edition : 1st
Language : English
ISBN-13 : 9781783985135
Category :
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 16, 2015
Length: 504 pages
Edition : 1st
Language : English
ISBN-13 : 9781783985135
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 133.97
Mastering Predictive Analytics with R
€41.99
Learning Pandas
€49.99
Practical Data Analysis
€41.99
Total $ 133.97 Stars icon

Table of Contents

13 Chapters
1. A Tour of pandas Chevron down icon Chevron up icon
2. Installing pandas Chevron down icon Chevron up icon
3. NumPy for pandas Chevron down icon Chevron up icon
4. The pandas Series Object Chevron down icon Chevron up icon
5. The pandas DataFrame Object Chevron down icon Chevron up icon
6. Accessing Data Chevron down icon Chevron up icon
7. Tidying Up Your Data Chevron down icon Chevron up icon
8. Combining and Reshaping Data Chevron down icon Chevron up icon
9. Grouping and Aggregating Data Chevron down icon Chevron up icon
10. Time-series Data Chevron down icon Chevron up icon
11. Visualization Chevron down icon Chevron up icon
12. Applications to Finance Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(10 Ratings)
5 star 50%
4 star 40%
3 star 0%
2 star 0%
1 star 10%
Filter icon Filter
Top Reviews

Filter reviews by




Natester Jun 06, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've been working with the pandas library for a while but had been looking for a text to help navigate the rich feature set of the pandas library. I purchased this book as soon as it became available and I'm quite satisfied with the content.I skipped the first few chapters, but if you are new to Python and using Python packages, do be sure to go through the content.The next couple of chapters discuss the inner workings of pandas DataFrame and Series. Worth going through as it provides a foundation for the remainder of the book's examples.Around chapter 6 is where the application examples dig in and they are quite useful. I've referred to many of these examples. They include reading and writing data with different data sources, slicing and dicing data and running stats on your data.Examples towards the end of the book get progressively sophisticated with shaping data. I didn't read everything in those chapters, but towards the end of the book are some chapters on data visualization and working with time series data. Definitely a "must" if you are looking to make use of pandas in your data analysis work.I keep this ebook in my reference collection and refer to it when in need to figure out how to solve a data issue where pandas might be a good fit. A helpful book in the Python + data space.
Amazon Verified review Amazon
Loris Jun 20, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
In my job I make use of many scientific libraries and Pandas is one of those. I have been looking for a good Pandas reference book for a while and I got this book as soon as it was published. I am not exaggerating when I say that it is one of the best python-related book I ever read. It is not only well written but it is also very well organized and structured. The book begins by providing detailed instructions on how to install Pandas on Linux, MacOS X, and Windows. In the firsts chapters it introduces NumPy and both Pandas Series and DataFrames. These firsts chapters are really important, especially for beginners, as they explain basic concepts that will be used continuously through the book. The author also indicates in which situations Pandas behave differently from NumPy, something I ignored before reading the book.I found very useful the description of the different ways to access rows and columns in DataFrames (loc, iloc, ix, etc.). The author clearly explains which is the best method to use in different scenarios and gives important tips regarding the performances of the different methods. Personally the chapters I found more useful were those about “Tidying Up your Data”, “Combining and Reshaping Data”, and “Grouping and Aggregating Data”. These are not easy concepts and the author did a very good job explaining them and providing a lot of clear examples. I believe these chapters are where you realize how Pandas can greatly simplify data analysis. The chapter about visualization is particularly useful to those who do not have experience with matplotlib and want to learn how to do quick plots with pandas.To conclude, the book is an excellent guide to Pandas not only if you are a beginner but also if you already have some experience with the library. Beside being well written, it covers all the mayor features of Pandas and each topic is complemented with a lot of code.
Amazon Verified review Amazon
Trevor May 20, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Warning! This is not a book for learning statistical methods of data analysis. Do not buy if that is what you are looking for. If you are interested in learning the tools for data analysis in python, then this book is for you.This book is great for anyone who wants to understand how to use the pandas library. The book is larger than most Packtpub books. The size is primarily due to the number of topics covered and the rich interactive set of examples to illustrate each topic.All the code in the book can be downloaded in the form of ipython notebooks. Which is by far the best learning median for python. This greatly enhances not only your ability to follow along with the examples, but to explore each topic yourself by altering the code to reinforce what you have learned.Also, the books really does the best job I've seen at building each piece of the puzzle one step at a time. The author assumes basic knowledge of python, and some familiarity with statistical definitions. Otherwise, nothing is referenced without first being explained, and everything is introduced in a logical way.If you want to understand how to use pandas from the ground up, then this book is for you.
Amazon Verified review Amazon
Harmon L. Jul 26, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent
Amazon Verified review Amazon
Lidija Novak Jan 05, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Its a beginners book and a bit outdated, still what counts is its content. Straight forward, sharp and great set up of content and examples. What I hate is meaningless nonsense, this author is great of keeping text short but informative.Have not yet finished reading the book but the first chapters have answered all my previous questions I had on Pandas after reading another book. Great buy! After this book I will buy Pandas for Finance written by same author - Michael Heydt!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Modal Close icon
Modal Close icon