Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Big Data Analysis with Python

You're reading from   Big Data Analysis with Python Combine Spark and Python to unlock the powers of parallel computing and machine learning

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781789955286
Length 276 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (3):
Arrow left icon
Ivan Marin Ivan Marin
Author Profile Icon Ivan Marin
Ivan Marin
Sarang VK Sarang VK
Author Profile Icon Sarang VK
Sarang VK
Ankit Shukla Ankit Shukla
Author Profile Icon Ankit Shukla
Ankit Shukla
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Big Data Analysis with Python
Preface
1. The Python Data Science Stack 2. Statistical Visualizations FREE CHAPTER 3. Working with Big Data Frameworks 4. Diving Deeper with Spark 5. Handling Missing Values and Correlation Analysis 6. Exploratory Data Analysis 7. Reproducibility in Big Data Analysis 8. Creating a Full Analysis Report Appendix

Pandas DataFrames and Grouped Data


As we learned in the previous chapter, when analyzing data and using Pandas to do so, we can use the plot functions from Pandas or use Matplotlib directly. Pandas uses Matplotlib under the hood, so the integration is great. Depending on the situation, we can either plot directly from pandas or create a figure and an axes with Matplotlib and pass it to pandas to plot. For example, when doing a GroupBy, we can separate the data into a GroupBy key. But how can we plot the results of GroupBy? We have a few approaches at our disposal. We can, for example, use pandas directly, if the DataFrame is already in the right format:

Note

The following code is a sample and will not get executed.

fig, ax = plt.subplots()
df = pd.read_csv('data/dow_jones_index.data')
df[df.stock.isin(['MSFT', 'GE', 'PG'])].groupby('stock')['volume'].plot(ax=ax)

Or we can just plot each GroupBy key on the same plot:

fig, ax = plt.subplots()
df.groupby('stock').volume.plot(ax=ax)

For the following...

You have been reading a chapter from
Big Data Analysis with Python
Published in: Apr 2019
Publisher: Packt
ISBN-13: 9781789955286
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 €18.99/month. Cancel anytime