Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Engineering with Python

You're reading from  Data Engineering with Python

Product type Book
Published in Oct 2020
Publisher Packt
ISBN-13 9781839214189
Pages 356 pages
Edition 1st Edition
Languages
Author (1):
Paul Crickard Paul Crickard
Profile icon Paul Crickard

Table of Contents (21) Chapters

Preface Section 1: Building Data Pipelines – Extract Transform, and Load
Chapter 1: What is Data Engineering? Chapter 2: Building Our Data Engineering Infrastructure Chapter 3: Reading and Writing Files Chapter 4: Working with Databases Chapter 5: Cleaning, Transforming, and Enriching Data Chapter 6: Building a 311 Data Pipeline Section 2:Deploying Data Pipelines in Production
Chapter 7: Features of a Production Pipeline Chapter 8: Version Control with the NiFi Registry Chapter 9: Monitoring Data Pipelines Chapter 10: Deploying Data Pipelines Chapter 11: Building a Production Data Pipeline Section 3:Beyond Batch – Building Real-Time Data Pipelines
Chapter 12: Building a Kafka Cluster Chapter 13: Streaming Data with Apache Kafka Chapter 14: Data Processing with Apache Spark Chapter 15: Real-Time Edge Data with MiNiFi, Kafka, and Spark Other Books You May Enjoy Appendix

Processing data with PySpark

Before processing data with PySpark, let's run one of the samples to show how Spark works. Then, we will skip the boilerplate in later examples and focus on data processing. The Jupyter notebook for the Pi Estimation example from the Spark website at http://spark.apache.org/examples.html is shown in the following screenshot:

Figure 14.6 – The Pi Estimation example in a Jupyter notebook

The example from the website will not run without some modifications. In the following points, I will walk through the cells:

  1. The first cell imports findspark and runs the init() method. This was explained in the preceding section as the preferred method to include PySpark in Jupyter notebooks. The code is as follows:
    import findspark
    findspark.init()
  2. The next cell imports the pyspark library and SparkSession. It then creates the session by passing the head node of the Spark cluster. You can get the URL from the Spark web UI...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}