Book Image

Python Business Intelligence Cookbook

Book Image

Python Business Intelligence Cookbook

Overview of this book

The amount of data produced by businesses and devices is going nowhere but up. In this scenario, the major advantage of Python is that it's a general-purpose language and gives you a lot of flexibility in data structures. Python is an excellent tool for more specialized analysis tasks, and is powered with related libraries to process data streams, to visualize datasets, and to carry out scientific calculations. Using Python for business intelligence (BI) can help you solve tricky problems in one go. Rather than spending day after day scouring Internet forums for “how-to” information, here you’ll find more than 60 recipes that take you through the entire process of creating actionable intelligence from your raw data, no matter what shape or form it’s in. Within the first 30 minutes of opening this book, you’ll learn how to use the latest in Python and NoSQL databases to glean insights from data just waiting to be exploited. We’ll begin with a quick-fire introduction to Python for BI and show you what problems Python solves. From there, we move on to working with a predefined data set to extract data as per business requirements, using the Pandas library and MongoDB as our storage engine. Next, we will analyze data and perform transformations for BI with Python. Through this, you will gather insightful data that will help you make informed decisions for your business. The final part of the book will show you the most important task of BI—visualizing data by building stunning dashboards using Matplotlib, PyTables, and iPython Notebook.
Table of Contents (12 chapters)
Python Business Intelligence Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Installing Anaconda


Throughout this book, we'll be using Python as the main tool for performing business intelligence tasks. This recipe shows you how to get a specific Python distribution—Anaconda, installed.

Getting ready

Regardless of which operating system you use, open a web browser and browse to the Anaconda download page at http://continuum.io/downloads.

The download page will automatically detect your operating system.

How to do it…

In this section, we have listed the steps to install Anaconda for all the major operating systems: Mac OS X, Windows, and Linux.

Mac OS X 10.10.4

  1. Click on the I WANT PYTHON 3.4 link. We'll be using Python 3.4 throughout this book.

  2. Next, click on the Mac OS X — 64-Bit Python 3.4 Graphical Installer button to download Anaconda.

  3. Once the download completes, browse your computer to find the downloaded Anaconda, and double-click on the Anaconda installer file (a .pkg file) to begin the installation.

  4. Walk through the installer steps to complete the installation. I recommend keeping the default settings.

  5. To verify that Anaconda is installed correctly, open a terminal and type the following command:

    python
    
  6. If the installer was successful, you should see something like this:

Windows 8.1

  1. Click on the I WANT PYTHON 3.4 link. We'll be using Python 3.4 throughout this book.

  2. Next, click on the Windows 64-Bit Python 3.4 Graphical Installer button to download Anaconda.

  3. Once the download completes, browse your computer to find the downloaded Anaconda, and double-click on the Anaconda3-2.3.0-Windows-x86_64.exe file to begin the installation.

  4. Walk through the installer steps to complete the installation. I recommend keeping the default settings.

  5. To verify that Anaconda has installed correctly, open a terminal, or open a command prompt in Windows. Now type the following command:

    python
    
  6. If the installation was successful, you should see something like this:

Linux Ubuntu server 14.04.2 LTS

Linux servers have no graphical user interface (GUI), so you'll first need to log into your server and get a command prompt. With that complete, do the following:

  1. On the Anaconda downloads page, select Linux.

  2. Choose the Python 3.4 link.

  3. Right-click on the Linux X 64-Bit button, and copy the link.

  4. At the command prompt on your server, use curl to download the file, pasting the following download link:

    curl –O <LINK TO DOWNLOAD>
    
  5. I've created a special shortcut on my website that is a bit easier to type at the command line: http://robertwdempsey.com/anaconda3-linux.

  6. Once Anaconda downloads, use the following command to start the installer:

    bash Anaconda3-2.3.0-Linux-x86_64.sh
    
  7. Accept the license agreement to begin installation.

  8. When asked if you would like Anaconda to prepend the Anaconda3 install location to the PATH variable, type yes.

    • To have the PATH update take effect immediately after the installation completes, type the following command in the command line:

      source ~/.bashrc
      
  9. Once the installation is complete, verify the installation by typing python in the command line. If everything worked correctly, you should see something like this:

How it works…

Anaconda holds many advantages over downloading Python from http://www.python.org or using the Python distribution included with your computer, some of which are as follows:

  • Almost 90 percent of what you'll use on a day-to-day basis is already included. In fact, it contains over 330 of the most popular Python packages.

  • Using Anaconda on both the computer you use for development and the server where your solutions will be deployed helps ensure that you are using the same version of the Python packages that your applications require.

  • It's constantly updated; so, you will always be using the latest version of Python and the Python packages.

  • It works on all the major operating systems—Linux, Mac, and Windows.

  • It comes with tools to connect and integrate with Microsoft Excel.

At the time of writing this, the current version of Anaconda for Python 3 is 2.3.0.