Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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
Data Processing with Optimus

You're reading from   Data Processing with Optimus Supercharge big data preparation tasks for analytics and machine learning with Optimus using Dask and PySpark

Arrow left icon
Product type Paperback
Published in Sep 2021
Publisher Packt
ISBN-13 9781801079563
Length 300 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Dr. Argenis Leon Dr. Argenis Leon
Author Profile Icon Dr. Argenis Leon
Dr. Argenis Leon
Luis Aguirre Contreras Luis Aguirre Contreras
Author Profile Icon Luis Aguirre Contreras
Luis Aguirre Contreras
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Section 1: Getting Started with Optimus
2. Chapter 1: Hi Optimus! FREE CHAPTER 3. Chapter 2: Data Loading, Saving, and File Formats 4. Section 2: Optimus – Transform and Rollout
5. Chapter 3: Data Wrangling 6. Chapter 4: Combining, Reshaping, and Aggregating Data 7. Chapter 5: Data Visualization and Profiling 8. Chapter 6: String Clustering 9. Chapter 7: Feature Engineering 10. Section 3: Advanced Features of Optimus
11. Chapter 8: Machine Learning 12. Chapter 9: Natural Language Processing 13. Chapter 10: Hacking Optimus 14. Chapter 11: Optimus as a Web Service 15. Other Books You May Enjoy

Reshaping and pivoting

In some cases, you'll want to make some more radical transformations to your dataset. In this section, we'll learn how to reshape an Optimus DataFrame in various ways, including pivoting, staking, and melting.

Pivoting

Pivoting is the process of reshaping stacked data into a new dataframe with simpler and less detailed data. It involves using the data of a column of choice and using it as column labels. Then, you must use one or more columns to group the data and calculate its values with the preferred summarization or aggregation over the rest of the data. The following is an example of this:

Figure 4.2 – How pivoting works

Let's look at an example of a dataset of sales that was made in a short period of time:

df = op.create.dataframe({
    "date": ["1/1/21", "1/1/21", "1/2/21", "1/2/21", "1/3/21", "1/3/21", &quot...
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 $19.99/month. Cancel anytime