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
Python Business Intelligence Cookbook
Python Business Intelligence Cookbook

Python Business Intelligence Cookbook: Leverage the computational power of Python with more than 60 recipes that arm you with the required skills to make informed business decisions

eBook
$9.99 $35.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

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

Python Business Intelligence Cookbook

Chapter 2. Making Your Data All It Can Be

In this chapter, we will cover the steps that you need to perform to get your data ready for analysis. You will learn about the following:

  • Importing data into MongoDB
    • Importing a CSV file into MongoDB
    • Importing an Excel file into MongoDB
    • Importing a JSON file into MongoDB
    • Importing a plain text file into MongoDB
  • Working with MongoDB using PyMongo
    • Retrieving a single record using PyMongo
    • Retrieving multiple records using PyMongo
    • Inserting a single record using PyMongo
    • Inserting multiple records using PyMongo
    • Updating a single record using PyMongo
    • Updating multiple records using PyMongo
    • Deleting a single record using PyMongo
    • Deleting multiple records using PyMongo
  • Cleaning data using Pandas
    • Importing a CSV File into a Pandas DataFrame
    • Renaming column headers in Pandas
    • Filling in missing values in Pandas
    • Removing punctuation in Pandas
    • Removing whitespace in Pandas
    • Removing any string from within a string in Pandas
  • Standardizing data with Pandas
    • Merging two datasets...

Importing a CSV file into MongoDB

Importing data from a CSV file into MongoDB is one of the fastest methods of import available. It is also one of the easiest. With almost every database system exporting to CSV, the following recipe is sure to come in handy.

Getting ready

The UK Road Safety Data comprises three CSV files: accidents7904.csv, casualty7904.csv, and vehicles7904.csv. Use this recipe to import the Accidents7904.csv file into MongoDB.

How to do it…

Run the following command at the command line:

./Applications/mongodb-3.0.4/bin/mongoimport --db pythonbicookbook --collection accidents --type csv --headerline --file '/Data/Stats19-Data1979-2004/Accidents7904.csv' --numInsertionWorkers 5

After running that command, you should see something similar to the following screenshot:

How to do it…

The following command is what you would use for Windows:

C:\Program Files\MongoDB\Server\3.0\bin\mongoimport --db pythonbicookbook --collection accidents --type csv --headerline --file C:\Data\Stats19...

Importing an Excel file into MongoDB

MongoDB does not support the direct import of Excel files, so to do that, we will use a function built into Excel.

Getting ready

The mongoimport utility supports only JSON, CSV, and TSV files. Therefore, to get your data from Excel into MongoDB, the best option is to save it as a CSV file, and then use mongoimport to import it.

How to do it…

In Excel:

  1. Go to the File menu.
  2. Select Save As.
  3. Save the file in the Comma Separated Values (CSV) format.

After you perform the preceding steps, you can use the previous recipe to import the file.

If you think that's too easy though, you can import the Excel file into a Pandas DataFrame using read_excel, write the entire DataFrame to a CSV file using to_csv, and then import it using mongoimport. I highly recommend the first and much easier option.

How it works…

This recipe works almost exactly like our previous recipe for importing a CSV file; only here, we start with an Excel file, which we save as a CSV...

Importing a JSON file into MongoDB

JavaScript Object Notation (JSON) is becoming the number one format for data exchange on the Web. Modern REST APIs return data in the JSON format, and MongoDB stores the records as binary-encoded JSON documents called BSON. Use the following recipe to import JSON documents into MongoDB.

Getting ready

As we've done in previous import recipes, we'll be using the mongoimport utility to import the data in the JSON file into MongoDB. By default, mongoimport expects a JSON file unless told otherwise.

How to do it…

The command for importing a JSON file is almost the same as we used for importing a CSV file:

./Applications/mongodb-3.0.4/bin/mongoimport --db pythonbicookbook --collection accidents --type json --headerline --file '/Data/Stats19-Data1979-2004/Accidents7904.json' --numInsertionWorkers 5

Importing a plain text file into MongoDB

Let us say that you have a text file that you need to import into MongoDB so you can make it searchable. This file is not comma or tab separated; it just has a lot of text which you want to keep. Use the following recipe to import it:

How to do it…

from pymongo import MongoClient
client = MongoClient()
db = client.pythonbicookbook
files = db.files
f = open('name_of_file_here.txt')
text = f.read()
doc = {
"file_name": "name_of_file_here.txt",
"contents" : text }
files.insert(doc)

The first thing we do is import PyMongo and create a connection to the database. We then tell PyMongo the name of the collection that we want to use; in this instance, the files collection. Next we use the built-in file handling functionality of Python to open a file and read its contents into a variable. After that, we build our document, and finally insert it into MongoDB using the insert method.

How it works…

Using PyMongo...

Retrieving a single record using PyMongo

Retrieving a single record is a common operation in any system with the CRUD (Create Read Update Delete) functionality.

Getting ready

PyMongo has a method that allows us to easily query a single record using zero or more criteria: find_one().

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
accidents = db.accidents
# Find the first document in the collection
accidents.find_one()
# Find the first document in the collection where the accident happened on a Sunday
accidents.find_one({"Day_of_Week": 1})

How it works…

The find_one() method returns a single document—the first one it finds—based on the criteria provided. If there are multiple records found, find_one() will return the first match. If only one record is found, that will be returned.

Retrieving multiple records using PyMongo

In order to produce a list view on a web page, or to pull more than a single record out of MongoDB, say, for analysis, you will need to query for multiple records.

Getting ready

PyMongo provides a find() function that we can use to search for multiple documents that match a given criteria, returning a cursor instance that we can iterate over.

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
accidents = db.accidents
# Retrieve all records where the accident happened on a Friday
data = accidents.find({"Day_of_Week": 7})
# Show a count for the result
data.count() # returns 896218

How it works…

The find() function is a powerful method for filtering a result set to get only the records that you want. You can search on a single field, as we have in this recipe, or search on multiple fields. In addition, you can limit your results to a subset of the available...

Importing a CSV file into MongoDB


Importing data from a CSV file into MongoDB is one of the fastest methods of import available. It is also one of the easiest. With almost every database system exporting to CSV, the following recipe is sure to come in handy.

Getting ready

The UK Road Safety Data comprises three CSV files: accidents7904.csv, casualty7904.csv, and vehicles7904.csv. Use this recipe to import the Accidents7904.csv file into MongoDB.

How to do it…

Run the following command at the command line:

./Applications/mongodb-3.0.4/bin/mongoimport --db pythonbicookbook --collection accidents --type csv --headerline --file '/Data/Stats19-Data1979-2004/Accidents7904.csv' --numInsertionWorkers 5

After running that command, you should see something similar to the following screenshot:

The following command is what you would use for Windows:

C:\Program Files\MongoDB\Server\3.0\bin\mongoimport --db pythonbicookbook --collection accidents --type csv --headerline --file C:\Data\Stats19-Data1979-2004...

Importing an Excel file into MongoDB


MongoDB does not support the direct import of Excel files, so to do that, we will use a function built into Excel.

Getting ready

The mongoimport utility supports only JSON, CSV, and TSV files. Therefore, to get your data from Excel into MongoDB, the best option is to save it as a CSV file, and then use mongoimport to import it.

How to do it…

In Excel:

  1. Go to the File menu.

  2. Select Save As.

  3. Save the file in the Comma Separated Values (CSV) format.

After you perform the preceding steps, you can use the previous recipe to import the file.

If you think that's too easy though, you can import the Excel file into a Pandas DataFrame using read_excel, write the entire DataFrame to a CSV file using to_csv, and then import it using mongoimport. I highly recommend the first and much easier option.

How it works…

This recipe works almost exactly like our previous recipe for importing a CSV file; only here, we start with an Excel file, which we save as a CSV file.

Importing a JSON file into MongoDB


JavaScript Object Notation (JSON) is becoming the number one format for data exchange on the Web. Modern REST APIs return data in the JSON format, and MongoDB stores the records as binary-encoded JSON documents called BSON. Use the following recipe to import JSON documents into MongoDB.

Getting ready

As we've done in previous import recipes, we'll be using the mongoimport utility to import the data in the JSON file into MongoDB. By default, mongoimport expects a JSON file unless told otherwise.

How to do it…

The command for importing a JSON file is almost the same as we used for importing a CSV file:

./Applications/mongodb-3.0.4/bin/mongoimport --db pythonbicookbook --collection accidents --type json --headerline --file '/Data/Stats19-Data1979-2004/Accidents7904.json' --numInsertionWorkers 5

Importing a plain text file into MongoDB


Let us say that you have a text file that you need to import into MongoDB so you can make it searchable. This file is not comma or tab separated; it just has a lot of text which you want to keep. Use the following recipe to import it:

How to do it…

from pymongo import MongoClient
client = MongoClient()
db = client.pythonbicookbook
files = db.files
f = open('name_of_file_here.txt')
text = f.read()
doc = {
"file_name": "name_of_file_here.txt",
"contents" : text }
files.insert(doc)

The first thing we do is import PyMongo and create a connection to the database. We then tell PyMongo the name of the collection that we want to use; in this instance, the files collection. Next we use the built-in file handling functionality of Python to open a file and read its contents into a variable. After that, we build our document, and finally insert it into MongoDB using the insert method.

How it works…

Using PyMongo, the script creates a connection to MongoDB, specifies...

Retrieving a single record using PyMongo


Retrieving a single record is a common operation in any system with the CRUD (Create Read Update Delete) functionality.

Getting ready

PyMongo has a method that allows us to easily query a single record using zero or more criteria: find_one().

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
accidents = db.accidents
# Find the first document in the collection
accidents.find_one()
# Find the first document in the collection where the accident happened on a Sunday
accidents.find_one({"Day_of_Week": 1})

How it works…

The find_one() method returns a single document—the first one it finds—based on the criteria provided. If there are multiple records found, find_one() will return the first match. If only one record is found, that will be returned.

Retrieving multiple records using PyMongo


In order to produce a list view on a web page, or to pull more than a single record out of MongoDB, say, for analysis, you will need to query for multiple records.

Getting ready

PyMongo provides a find() function that we can use to search for multiple documents that match a given criteria, returning a cursor instance that we can iterate over.

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
accidents = db.accidents
# Retrieve all records where the accident happened on a Friday
data = accidents.find({"Day_of_Week": 7})
# Show a count for the result
data.count() # returns 896218

How it works…

The find() function is a powerful method for filtering a result set to get only the records that you want. You can search on a single field, as we have in this recipe, or search on multiple fields. In addition, you can limit your results to a subset of the available fields using the projection argument...

Inserting a single record using PyMongo


In order to produce actionable insights from your business intelligence system, you will more than likely need to combine data sources. Let us say that you have

Getting ready

In order to insert a record, we first create the record and then insert it. The new record needs to be in the JSON format.

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
customers = db.customers
import datetime
new_customer = {"first_name": "Bob",
                "last_name": "Smith",
                "address_1": "123 Main Street",
                "address_2": "Suite 200",
                "city": "Washington",
                "state": "DC",
                "zipcode": "20036",
                "interests": ["product_1", "product_4", "product_7"],
                "contact_requested": True,
                "created_at": datetime.datetime.utcnow(),
                "updated_at": datetime.datetime.utcnow()}
customer_id...

Inserting multiple records using PyMongo


Many applications need to support the bulk importing of records. PyMongo makes this easy with the insert_many() method.

Getting ready

In order to insert multiple records, we need to first create a list of documents to insert, and then compile them into a single python list.

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
customers = db.customers
new_customers = [{"first_name": "Jane",
                    "last_name": "Doe",
                    "address_1": "123 12th Street NW",
                    "address_2": "Suite 1200",
                    "city": "Washington",
                "state": "DC",
                "zipcode": "20036",
                "interests": ["product_2", "product_3", "product_8"],
                "contact_requested": False,
                "created_at": datetime.datetime.utcnow(),
                "updated_at": datetime.datetime.utcnow()},
                 {"first_name...

Updating a single record using PyMongo


A common operation in every application is that of updating a single record. For that, we'll use find_one_and_update() provided by PyMongo.

Getting ready

The find_one_and_update() method requires a filter to determine the record to be updated.

How to do it…

The following code tells us how to update a single record using PyMongo:

# Find the record you want to update and save the ID
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
customers = db.customers
customers.find_one_and_update(
    {"first_name": "Bob", "last_name": "Smith"},
    {'$set': {'contacted': False,
 'updated_at': datetime.datetime.utcnow()}})

How it works…

The first thing we do is create a filter for the update. In this recipe, we look for a record where the first_name field is Bob and the last_name field is Smith. Next, we tell PyMongo about the update operation that is to be applied. Here, we're telling PyMongo to set contacted to False...

Updating multiple records using PyMongo


When you need to update many records at once, which can be the case when you need a new field added to all the existing records, use the update_many() function.

Getting ready

As with find_one_and_update(), we first need to create a filter for the records that we want to update.

How to do it…

The following code tells us how to update multiple records using PyMongo:

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
customers = db.customers
result = customers.update_many(
            { 'first_name': {
'$exists': True }
},
            {'$currentDate': {
                'updated_at': { $type: "timestamp" }
         },
'$set': {
'contacted': False
             }})
print(result.matched_count)

How it works…

In this recipe, we are setting the contacted key to False for all the customer records that have a first name and updated_at to the time of the update. We then print out the count of records that were updated...

Deleting a single record using pymongo


Sometimes, you just need to delete a record. That's easy with the delete_one() method.

Getting ready

As we've seen in the previous recipes, the first thing to do is to create a filter to find the record to delete.

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
customers = db.customers
result = customers.delete_one({
'first_name': 'Bob',
'last_name': 'Smith' })
print(result.deleted_count)

How it works…

Given a filter, delete_one() deletes the first record that matches the filter. We then print out the count of records deleted to ensure that only one record was deleted.

Deleting multiple records using PyMongo


Sometimes, you need to delete a single record, while at other times you need to delete many. This recipe shows you how to delete multiple records matching a filter.

Getting ready

As before, determine the records that you want to delete, and create a filter for them.

How to do it…

from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pythonbicookbook
customers = db.customers
result = customers.delete_many({
'contact_requested': False })
print(result.deleted_count)

How it works…

Given a filter, delete_many() deletes all the records matching the filter. We then print out the number of records deleted.

Importing a CSV file into a Pandas DataFrame


Pandas is an open-source, high-performance library that provides easy-to-use data structures and data analysis tools for Python. Pandas was created to aid in the analysis of time series data, and has become a standard in the Python community. Not only does it provide data structures, such as a Series and a DataFrame, that help with all aspects of data science, it also has built-in analysis methods which we'll use later in the book.

Before we can start cleaning and standardizing data using Pandas, we need to get the data into a Pandas DataFrame, the primary data structure of Pandas. You can think of a DataFrame like an Excel document—it has rows and columns. Once data is in a DataFrame, we can use the full power of Pandas to manipulate and query it.

Getting ready

Pandas provides a highly configurable function—read_csv()—that we'll use to import our data. On a modern laptop with 4+ GB of RAM, we can easily and quickly import the entire accidents dataset...

Renaming column headers in Pandas


When importing a file into a Pandas DataFrame, Pandas will use the first line of the file as the column names. If you have repeated names, Pandas will add .1 to the column name. Many times this is not ideal. The following recipe shows you how to rename the column headers in a Pandas DataFrame.

Getting ready

Create a Pandas DataFrame from a file of customer data:

import pandas as pd
import numpy as np
data_file = '../Data/customer_data.csv'
customers = pd.DataFrame.from_csv(data_file,
                       header=0,
                       sep=',',
                       index_col=0,
    encoding=None,
                       tupleize_cols=False)

How to do it…

customers.rename(columns={
                 'birth date': 'date_of_birth',
                 'customer loyalty level': 'customer_loyalty_level',
                 'first name': 'first_name',
                 'last name': 'last_name',
                 'ssn': 'social_security_number',
                 'postcode...

Filling in missing values in Pandas


While we would love to obtain datasets that contain no missing values whatsoever, the reality is that we almost always have to handle them. This recipe shows you four methods that you can use.

Getting ready

Pandas provides a fillna() method to fill in missing values. Create a DataFrame from the customer data using the previous recipe, and then try each of the following methods.

How to do it…

The following code tells us how to fill in missing values in Pandas:

# 1: Replace all missing values with a string - 'Missing'
customers.fillna('Missing', inplace=True)
# 2: Replace all missing values with a 0
customers.fillna(0, inplace=True)
# 3: Replace all missing values with the mean of the DataFrame
customers.fillna(raw_data.mean(), inplace=True)
# 4. Replace the missing values of a single colum with the mean of that column
customers['marketing_score'].fillna(raw_data.mean()['marketing_score'], inplace=True)

How it works…

Each of the preceding methods uses the fillna...

Removing punctuation in Pandas


When performing string comparisons on your data, certain things like punctuation might not matter. In this recipe, you'll learn how to remove punctuation from a column in a DataFrame.

Getting ready

Part of the power of Pandas is applying a custom function to an entire column at once. Create a DataFrame from the customer data, and use the following recipe to update the last_name column.

How to do it…

import string
exclude = set(string.punctuation)
def remove_punctuation(x):
    """
    Helper function to remove punctuation from a string
    x: any string
    """
    try:
        x = ''.join(ch for ch in x if ch not in exclude)
    except:
        pass
    return x
# Apply the function to the DataFrame
customers.last_name = customers.last_name.apply(remove_punctuation)

How it works…

We first import the string class from the Python standard library. Next, we create a Python set named exclude from string.punctuation, which is a string containing all the ASCII punctuation...

Removing whitespace in Pandas


It is very common to find whitespace at the beginning, the end, or the inside of a string, whether it's data in a CSV file or data from another source. Use the following recipe to create a custom function to remove the whitespace from every row of a column in a Pandas DataFrame.

Getting ready

Continue using the customers DataFrame you created earlier, or import the file into a new DataFrame.

How to do it…

def remove_whitespace(x):
    """
    Helper function to remove any blank space from a string
    x: a string
    """
    try:
        # Remove spaces inside of the string
        x = "".join(x.split())

    except:
        pass
    return x

customers.last_name = customers.last_name.apply(remove_whitespace)

How it works…

We first create a custom function named remove_whitespace() that takes a string as an argument. The function removes any single space it finds, and returns the cleaned string. Then, just as in the previous recipe, we apply the function to the last_name...

Removing any string from within a string in Pandas


Often, you'll find that you need to remove one or more characters from within a string. Real-world examples of this include internal abbreviations such as FKA (Formerly Known As) or suffixes such as Jr. or Sr.

Getting ready

Continue using the customer's DataFrame you created earlier, or import the file into a new DataFrame.

How to do it…

def remove_internal_abbreviations(s, thing_to_replace, replacement_string):
    """
    Helper function to remove one or movre characters from a string
    s: the full string
    thing_to_replace: what you want to replace in the given string
    replacement_string: the string to use as a replacement
    """
    try:
        s = s.replace(thing_to_replace, replacement_string)
    except:
        pass
    return s

customers['last_name'] = customers.apply(lambda x: remove_internal_abbreviations(x['last_name'], "FKA", "-"), axis=1)

How it works…

We first create a custom function that takes three arguments:

  • s: the...

Merging two datasets in Pandas


In order to show a consolidated view of the data contained in two datasets, you need to merge them. Pandas has a built-in functionality to perform SQL-like joins of two DataFrames.

Getting ready

Create two DataFrames, one each from the accident and casualty datasets:

import pandas as pd
accidents_data_file = 'Accidents7904.csv'
casualty_data_file = 'Casualty7904.csv'
af = base_file_path + accidents_data_file
# Create a DataFrame from the accidents data
accidents = pd.read_csv(af,
                        sep=',',
                        header=0,
                        index_col=0,
                        parse_dates=False,
                        tupleize_cols=False,
                        error_bad_lines=False,
                        warn_bad_lines=False,
                        skip_blank_lines=True,
                        nrows=1000
                        )
# Create a DataFrame from the casualty data
cf = base_file_path + casualty_data_file
casualties...
Left arrow icon Right arrow icon

Key benefits

  • *Want to minimize risk and optimize profits of your business? Learn to create efficient analytical reports with ease using this highly practical, easy-to-follow guide.
  • *Learn to apply Python for business intelligence tasks—preparing, exploring, analyzing, visualizing and reporting—in order to make more informed business decisions using data at hand
  • *Learn to explore and analyze business data, and build business intelligence dashboards with the help of various insightful recipes

Description

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.

Who is this book for?

This book is intended for data analysts, managers, and executives with a basic knowledge of Python, who now want to use Python for their BI tasks. If you have a good knowledge and understanding of BI applications and have a “working” system in place, this book will enhance your toolbox.

What you will learn

  • * Install Anaconda, MongoDB, and everything you need to get started with your data analysis
  • * Prepare data for analysis by querying cleaning and standardizing data
  • * Explore your data by creating a Pandas data frame from MongoDB
  • * Gain powerful insights, both statistical and predictive, to make informed business decisions
  • * Visualize your data by building dashboards and generating reports
  • * Create a complete data processing and business intelligence system
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 22, 2015
Length: 202 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287466
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : Dec 22, 2015
Length: 202 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287466
Category :
Languages :

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 $ 141.97
Python GUI Programming Cookbook
$48.99
Python Data Visualization Cookbook (Second Edition)
$48.99
Python Business Intelligence Cookbook
$43.99
Total $ 141.97 Stars icon

Table of Contents

6 Chapters
1. Getting Set Up to Gain Business Intelligence Chevron down icon Chevron up icon
2. Making Your Data All It Can Be Chevron down icon Chevron up icon
3. Learning What Your Data Truly Holds Chevron down icon Chevron up icon
4. Performing Data Analysis for Non Data Analysts Chevron down icon Chevron up icon
5. Building a Business Intelligence Dashboard Quickly 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 Half star icon Empty star icon 3.6
(9 Ratings)
5 star 33.3%
4 star 11.1%
3 star 33.3%
2 star 22.2%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




CS Mar 22, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book for all Python programmers wanting to implement BI functionalities. Well, it covers only one database, which is MongoDB, but you can always start with something. This book has good content and lot of recipes that cover setting up your environment, importing data, cleanig up of data and then analyzing it. Good book to start with, if you are into Python and BI functionalities.
Amazon Verified review Amazon
Rook501 Feb 11, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is precisely what I was looking for. Python is great with data and generating valuable business intelligence and this book does a great job getting you started.
Amazon Verified review Amazon
Utsav Narayan Singh Jan 13, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book provides a good coverage of all topics for anyone planning to develop business intelligence solutions using Python. The books provides many recipies that cover setting up your environment, importing data, cleanig up of data and then analysing it. A promninent feature of the book is that it is platform agnostic and is suitable for everyone whether he is using Windows, Linx or OSX. I thouroughly enjoyed discovering new recipies in this book and jave used it as a reference from time to time.Note: I was reviewer of this book.
Amazon Verified review Amazon
Alex Meadows Feb 15, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Python Business Intelligence Cookbook is a good introduction to the basics of Pandas and working with csv files and MongoDB. One of the books few shortcomings is the lack of recipes showing interaction with a traditional RDBMS. While it can be understood that due to the variety and intermediate complexity that accessing a SQL database directly is out of scope for the book, it would have been nice to provide some reference to start with. That said, the various data types and process for analyzing, organizing, and visualizing data is spot on. The author even dives into predictive analytics. If you are looking for a general overview then this is a decent place to start.To note: I was asked by the publisher to provide this review in return for a free book. This did not impact my review.
Amazon Verified review Amazon
Ed P Feb 09, 2016
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
If you are Python programmer introducing BI functionality to your applications then this would be a good starting point. The content is reasonably good, but for many of the tasks covered, similar results could be achieved much quicker and easier with dedicated Business Intelligence tools for ETL and reporting. Also, the database used is MongoDB. There is no coverage of many popular NoSQL and RDBMS systems such as MySQL, PostgreSQL, SQL Server, Hadoop and Oracle that are likely to be used in the corporate world. But as a starting point some of these recipes could be adapted to use other systems as well. All in all, a decent effort, but somewhat limited in applicability
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon