Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Azure Synapse Analytics Cookbook

You're reading from   Azure Synapse Analytics Cookbook Implement a limitless analytical platform using effective recipes for Azure Synapse

Arrow left icon
Product type Paperback
Published in Apr 2022
Publisher Packt
ISBN-13 9781803231501
Length 238 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Gaurav Agarwal(BLR) Gaurav Agarwal(BLR)
Author Profile Icon Gaurav Agarwal(BLR)
Gaurav Agarwal(BLR)
Meenakshi Muralidharan Meenakshi Muralidharan
Author Profile Icon Meenakshi Muralidharan
Meenakshi Muralidharan
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Chapter 1: Choosing the Optimal Method for Loading Data to Synapse 2. Chapter 2: Creating Robust Data Pipelines and Data Transformation FREE CHAPTER 3. Chapter 3: Processing Data Optimally across Multiple Nodes 4. Chapter 4: Engineering Real-Time Analytics with Azure Synapse Link Using Cosmos DB 5. Chapter 5: Data Transformation and Processing with Synapse Notebooks 6. Chapter 6: Enriching Data Using the Azure ML AutoML Regression Model 7. Chapter 7: Visualizing and Reporting Petabytes of Data 8. Chapter 8: Data Cataloging and Governance 9. Chapter 9: MPP Platform Migration to Synapse 10. Other Books You May Enjoy

Visualizing data in a Synapse notebook

Let's now look at an interesting aspect of data exploration that will involve plotting some interesting visuals within the Synapse notebook. We all know that it is always easier to understand pictures or graphs compared to a typical dataset in rows and columns, for example, when you are dealing with a very large dataset, which may contain a lot of key insights. To obtain data-driven insights, we try to work on data pointers that will lead us to those insights; to do that, we plot the data in the form of a visual.

This is exactly what we will be doing in this recipe, and you will learn how to do this within the notebook experience.

Getting ready

We will be leveraging the same data frame that we created in the Reading and writing data from ADLS Gen2 using PySpark recipe.

Basic knowledge of matplotlib is required, which will help you to create static and interactive Python visuals.

How to do it…

Let's get back to the same notebook, PySparkNotebook, that we published in the Reading and writing data from ADLS Gen2 using PySpark recipe:

  1. Import matplotlib.pyplot:
    import matplotlib.pyplot as plt

This is the visualization plotting library in Python, as shown in Figure 2.6:

Figure 2.9 – matplotlib import

Figure 2.9 – matplotlib import

  1. Define and load the entire data frame to pandas using the toPandas() function, and define the chart type that we want to plot. In our case, it will be a histogram, which will give us the distribution for the total passenger count:
    mydataframeplot = mydataframe1.toPandas()
    ax = mydataframeplot['passenger_count'].plot(kind='hist', bins= 20, facecolor='orange')
    ax.set_title('Total Passenger distribution')
    ax.set_xlabel('No. of Passengers')
    ax.set_ylabel('Counts')
    chartplt.suptitle('Trend')
    chartplt.show()

Figure 2.10 shows the output:

Figure 2.10 – Plotting a histogram

Figure 2.10 – Plotting a histogram

How it works…

This leverages the power of the Spark pool that you have created to perform data exploration. It makes the process of extracting useful insights from the data extremely fast. The notebook experience within Synapse makes it a one-stop-shop for the developer and the data analyst to collaborate and perform their respective activities.

You have been reading a chapter from
Azure Synapse Analytics Cookbook
Published in: Apr 2022
Publisher: Packt
ISBN-13: 9781803231501
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 $19.99/month. Cancel anytime
Banner background image