Book description
Combine the power of Apache Spark and Python to build effective big data applications
About This Book- Perform effective data processing, machine learning, and analytics using PySpark
- Overcome challenges in developing and deploying Spark solutions using Python
- Explore recipes for efficiently combining Python and Apache Spark to process data
The PySpark Cookbook is for you if you are a Python developer looking for hands-on recipes for using the Apache Spark 2.x ecosystem in the best possible way. A thorough understanding of Python (and some familiarity with Spark) will help you get the best out of the book.
What You Will Learn- Configure a local instance of PySpark in a virtual environment
- Install and configure Jupyter in local and multi-node environments
- Create DataFrames from JSON and a dictionary using pyspark.sql
- Explore regression and clustering models available in the ML module
- Use DataFrames to transform data used for modeling
- Connect to PubNub and perform aggregations on streams
Apache Spark is an open source framework for efficient cluster computing with a strong interface for data parallelism and fault tolerance. The PySpark Cookbook presents effective and time-saving recipes for leveraging the power of Python and putting it to use in the Spark ecosystem.
You'll start by learning the Apache Spark architecture and how to set up a Python environment for Spark. You'll then get familiar with the modules available in PySpark and start using them effortlessly. In addition to this, you'll discover how to abstract data with RDDs and DataFrames, and understand the streaming capabilities of PySpark. You'll then move on to using ML and MLlib in order to solve any problems related to the machine learning capabilities of PySpark and use GraphFrames to solve graph-processing problems. Finally, you will explore how to deploy your applications to the cloud using the spark-submit command.
By the end of this book, you will be able to use the Python API for Apache Spark to solve any problems associated with building data-intensive applications.
Style and approachThis book is a rich collection of recipes that will come in handy when you are working with PySpark
Addressing your common and not-so-common pain points, this is a book that you must have on the shelf.
Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
- Installing and Configuring Spark
-
Abstracting Data with RDDs
- Introduction
- Creating RDDs
- Reading data from files
-
Overview of RDD transformations
- Getting ready
-
How to do it...
- .map(...) transformation
- .filter(...) transformation
- .flatMap(...) transformation
- .distinct() transformation
- .sample(...) transformation
- .join(...) transformation
- .repartition(...) transformation
- .zipWithIndex() transformation
- .reduceByKey(...) transformation
- .sortByKey(...) transformation
- .union(...) transformation
- .mapPartitionsWithIndex(...) transformation
- How it works...
- Overview of RDD actions
- Pitfalls of using RDDs
-
Abstracting Data with DataFrames
- Introduction
- Creating DataFrames
- Accessing underlying RDDs
- Performance optimizations
- Inferring the schema using reflection
- Specifying the schema programmatically
- Creating a temporary table
- Using SQL to interact with DataFrames
-
Overview of DataFrame transformations
- Getting ready
-
How to do it...
- The .select(...) transformation
- The .filter(...) transformation
- The .groupBy(...) transformation
- The .orderBy(...) transformation
- The .withColumn(...) transformation
- The .join(...) transformation
- The .unionAll(...) transformation
- The .distinct(...) transformation
- The .repartition(...) transformation
- The .fillna(...) transformation
- The .dropna(...) transformation
- The .dropDuplicates(...) transformation
- The .summary() and .describe() transformations
- The .freqItems(...) transformation
- See also
- Overview of DataFrame actions
- Preparing Data for Modeling
- Machine Learning with MLlib
-
Machine Learning with the ML Module
- Introducing Transformers
- Introducing Estimators
- Introducing Pipelines
- Selecting the most predictable features
- Predicting forest coverage types
- Estimating forest elevation
- Clustering forest cover types
- Tuning hyperparameters
- Extracting features from text
- Discretizing continuous variables
- Standardizing continuous variables
- Topic mining
- Structured Streaming with PySpark
- GraphFrames – Graph Theory with PySpark
Product information
- Title: PySpark Cookbook
- Author(s):
- Release date: June 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788835367
You might also like
book
Spark: The Definitive Guide
Learn how to use, deploy, and maintain Apache Spark with this comprehensive guide, written by the …
book
AWS Cookbook
This practical guide provides over 70 self-contained recipes to help you creatively solve common AWS challenges …
book
Python Cookbook, 3rd Edition
If you need help writing programs in Python 3, or want to update older Python 2 …
book
Kafka: The Definitive Guide
Every enterprise application creates data, whether it’s log messages, metrics, user activity, outgoing messages, or something …