Book Image

Big Data Analysis with Python

By : Ivan Marin, Ankit Shukla, Sarang VK
Book Image

Big Data Analysis with Python

By: Ivan Marin, Ankit Shukla, Sarang VK

Overview of this book

Processing big data in real time is challenging due to scalability, information inconsistency, and fault tolerance. Big Data Analysis with Python teaches you how to use tools that can control this data avalanche for you. With this book, you'll learn practical techniques to aggregate data into useful dimensions for posterior analysis, extract statistical measurements, and transform datasets into features for other systems. The book begins with an introduction to data manipulation in Python using pandas. You'll then get familiar with statistical analysis and plotting techniques. With multiple hands-on activities in store, you'll be able to analyze data that is distributed on several computers by using Dask. As you progress, you'll study how to aggregate data for plots when the entire data cannot be accommodated in memory. You'll also explore Hadoop (HDFS and YARN), which will help you tackle larger datasets. The book also covers Spark and explains how it interacts with other tools. By the end of this book, you'll be able to bootstrap your own Python environment, process large files, and manipulate data to generate statistics, metrics, and graphs.
Table of Contents (11 chapters)
Big Data Analysis with Python
Preface

Preface

Note

About

This section briefly introduces the authors, the what this book covers, the technical skills you'll need to get started, and the hardware and software requirements required to complete the activities and exercises.

About the Book

Processing big data in real time is challenging due to scalability, information inconsistency, and fault tolerance. Big Data Analysis with Python teaches you how to use tools that can control this data avalanche for you. With this book, you'll learn practical techniques to aggregate data into useful dimensions for posterior analysis, extract statistical measurements, and transform datasets into features for other systems.

The book begins with an introduction to data manipulation in Python using pandas. You'll then get familiar with statistical analysis and plotting techniques. With multiple hands-on activities in store, you'll be able to analyze data that is distributed on several computers by using Dask. As you progress, you'll study how to aggregate data for plots when the entire data cannot be accommodated in memory. You'll also explore Hadoop (HDFS and YARN), which will help you tackle larger datasets. The book also covers Spark and explains how it interacts with other tools.

By the end of this book, you'll be able to bootstrap your own Python environment, process large files, and manipulate data to generate statistics, metrics, and graphs.

About the Authors

Ivan Marin is a systems architect and data scientist working at Daitan Group, a Campinas-based software company. He designs big data systems for large volumes of data and implements machine learning pipelines end to end using Python and Spark. He is also an active organizer of data science, machine learning, and Python in São Paulo, and has given Python for data science courses at university level.

Ankit Shukla is a data scientist working with World Wide Technology, a leading US-based technology solution provider, where he develops and deploys machine learning and artificial intelligence solutions to solve business problems and create actual dollar value for clients. He is also part of the company's R&D initiative, which is responsible for producing intellectual property, building capabilities in new areas, and publishing cutting-edge research in corporate white papers. Besides tinkering with AI/ML models, he likes to read and is a big-time foodie.

Sarang VK is a lead data scientist at StraitsBridge Advisors, where his responsibilities include requirement gathering, solutioning, development, and productization of scalable machine learning, artificial intelligence, and analytical solutions using open source technologies. Alongside this, he supports pre-sales and competency.

Learning Objectives

  • Use Python to read and transform data into different formats

  • Generate basic statistics and metrics using data on disk

  • Work with computing tasks distributed over a cluster

  • Convert data from various sources into storage or querying formats

  • Prepare data for statistical analysis, visualization, and machine learning

  • Present data in the form of effective visuals

Approach

Big Data Analysis with Python takes a hands-on approach to understanding how to use Python and Spark to process data and make something useful out of it. It contains multiple activities that use real-life business scenarios for you to practice and apply your new skills in a highly relevant context.

Audience

Big Data Analysis with Python is designed for Python developers, data analysts, and data scientists who want to get hands-on with methods to control data and transform it into impactful insights. Basic knowledge of statistical measurements and relational databases will help you to understand various concepts explained in this book.

Minimum Hardware Requirements

For the optimal student experience, we recommend the following hardware configuration:

Processor: Intel or AMD 4-core or better

Memory: 8 GB RAM

Storage: 20 GB available space

Software Requirements

You'll need the following software installed in advance.

Any of the following operating systems:

  • Windows 7 SP1 32/64-bit

  • Windows 8.1 32/64-bit or Windows 10 32/64-bit

  • Ubuntu 14.04 or later

  • macOS Sierra or later

  • Browser: Google Chrome or Mozilla Firefox

  • Jupyter lab

You'll also need the following software installed in advance:

  • Python 3.5+

  • Anaconda 4.3+

These Python libraries are included with the Anaconda installation:

  • matplotlib 2.1.0+

  • iPython 6.1.0+

  • requests 2.18.4+

  • NumPy 1.13.1+

  • pandas 0.20.3+

  • scikit-learn 0.19.0+

  • seaborn 0.8.0+

  • bokeh 0.12.10+

These Python libraries require manual installation:

  • mlxtend

  • version_information

  • ipython-sql

  • pdir2

  • graphviz

Conventions

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To transform the data into the right data types, we can use conversion functions, such as to_datetime, to_numeric, and astype."

A block of code is set as follows:

before the sort function:[23, 66, 12, 54, 98, 3]
after the sort function: [3, 12, 23, 54, 66, 98]

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Pandas (https://pandas.pydata.org) is a data manipulation and analysis library that's widely used in the data science community."

Installation and Setup

Installing Anaconda:

  1. Visit https://www.anaconda.com/download/ in your browser.

  2. Click on Windows, Mac, or Linux, depending on the OS you are working on.

  3. Next, click on the Download option. Make sure you download the latest version.

  4. Open the installer after download.

  5. Follow the steps in the installer and that's it! Your Anaconda distribution is ready.

PySpark is available on PyPi. To install PySpark run the following command:

pip install pyspark --upgrade

Updating Jupyter and installing dependencies:

  1. Search for Anaconda Prompt and open it.

  2. Type the following commands to update Conda and Jupyter:

    #Update conda
    conda update conda
    
    #Update Jupyter
    conda update Jupyter
    
    #install packages
    conda install numpy
    conda install pandas
    conda install statsmodels
    conda install matplotlib
    conda install seaborn
  3. To open Jupyter Notebook from Anaconda Prompt, use the following command:

    jupyter notebook
    pip install -U scikit-learn

Installing the Code Bundle

Copy the code bundle for the class to the C:/Code folder.

Additional Resources

The code bundle for this book is also hosted on GitHub at: https://github.com/TrainingByPackt/Big-Data-Analysis-with-Python.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!