๐”– Scriptorium
โœฆ   LIBER   โœฆ

๐Ÿ“

Pandas Cookbook: Recipes for Scientific Computing, Time Series Analysis and Data Visualization using Python

โœ Scribed by Theodore Petrou


Publisher
Packt Publishing
Year
2017
Tongue
English
Leaves
534
Category
Library

โฌ‡  Acquire This Volume

No coin nor oath required. For personal study only.

โœฆ Synopsis


Publisher's Note: A new second edition, updated completely for pandas 1.x with additional chapters, has now been published. This edition from 2017 is outdated and is based on pandas 0.20.

Key Features

  • Use the power of pandas 0.20 to solve most complex scientific computing problems with ease
  • Leverage fast, robust data structures in pandas 0.20 to gain useful insights from your data
  • Practical, easy to implement recipes for quick solutions to common problems in data using pandas 0.20

Book Description

This book will provide you with unique, idiomatic, and fun recipes for both fundamental and advanced data manipulation tasks with pandas 0.20. Some recipes focus on achieving a deeper understanding of basic principles, or comparing and contrasting two similar operations. Other recipes will dive deep into a particular dataset, uncovering new and unexpected insights along the way.

The pandas library is massive, and it's common for frequent users to be unaware of many of its more impressive features. The official pandas documentation, while thorough, does not contain many useful examples of how to piece together multiple commands like one would do during an actual analysis. This book guides you, as if you were looking over the shoulder of an expert, through practical situations that you are highly likely to encounter.

Many advanced recipes combine several different features across the pandas 0.20 library to generate results.

What you will learn

  • Master the fundamentals of pandas 0.20 to quickly begin exploring any dataset
  • Isolate any subset of data by properly selecting and querying the data
  • Split data into independent groups before applying aggregations and transformations to each group
  • Restructure data into tidy form to make data analysis and visualization easier
  • Prepare real-world messy datasets for machine learning
  • Combine and merge data from different sources through pandas SQL-like operations
  • Utilize pandas unparalleled time series functionality
  • Create beautiful and insightful visualizations through pandas 0.20 direct hooks to Matplotlib and Seaborn

โœฆ Table of Contents


Cover
Copyright
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Pandas Foundations
Introduction
Dissecting the anatomy of a DataFrame
Getting ready
How to do it...
How it works...
There's more...
See also
Accessing the main DataFrame components
Getting ready
How to do it...
How it works...
There's more...
See also
Understanding data types
Getting ready
How to do it...
How it works...
There's more...
See also
Selecting a single column of data as a Series
Getting ready
How to do it...
How it works...
There's more...
See also
Calling Series methods
Getting ready
How to do it...
How it works...
There's more...
See also
Working with operators on a Series
Getting ready
How to do it...
How it works...
There's more...
See also
Chaining Series methods together
Getting ready
How to do it...
How it works...
There's more...
Making the index meaningful
Getting ready
How to do it...
How it works...
There's more...
See also
Renaming row and column names
Getting ready
How to do it...
How it works...
There's more...
Creating and deleting columns
Getting ready
How to do it...
How it works...
There's more...
See also
Essential Chapter 2: DataFrame Operations
Introduction
Selecting multiple DataFrame columns
Getting ready
How to do it...
How it works...
There's more...
Selecting columns with methods
Getting ready
How it works...
How it works...
There's more...
See also
Ordering column names sensibly
Getting ready
How to do it...
How it works...
There's more...
See also
Operating on the entire DataFrame
Getting ready
How to do it...
How it works...
There's more...
Chaining DataFrame methods together
Getting ready
How to do it...
How it works...
There's more...
See also
Working with operators on a DataFrame
Getting ready
How to do it...
How it works...
There's more...
See also
Comparing missing values
Getting ready
How to do it...
How it works...
There's more...
Transposing the direction of a DataFrame operation
Getting ready
How to do it...
How it works...
There's more...
See also
Determining college campus diversity
Getting ready
How to do it...
How it works...
There's more...
See also
Chapter 3: Beginning Data Analysis
Introduction
Developing a data analysis routine
Getting ready
How to do it...
How it works...
There's more...
Data dictionaries
See also
Reducing memory by changing data types
Getting ready
How to do it...
How it works...
There's more...
See also
Selecting the smallest of the largest
Getting ready
How to do it...
How it works...
There's more...
Selecting the largest of each group by sorting
Getting ready
How to do it...
How it works...
There's more...
Replicating nlargest with sort_values
Getting ready
How to do it...
How it works...
There's more...
Calculating a trailing stop order price
Getting ready
How to do it...
How it works...
There's more...
See also
Chapter 4: Selecting Subsets of Data
Introduction
Selecting Series data
Getting ready
How to do it...
How it works...
There's more...
See also
Selecting DataFrame rows
Getting ready
How to do it...
How it works...
There's more...
See also
Selecting DataFrame rows and columns simultaneously
Getting ready
How to do it...
How it works...
There's more...
Selecting data with both integers and labels
Getting ready
How to do it...
How it works...
There's more...
See also
Speeding up scalar selection
Getting ready
How to do it...
How it works...
There's more...
Slicing rows lazily
Getting ready
How to do it...
How it works...
There's more...
Slicing lexicographically
Getting ready
How to do it...
How it works...
There's more...
Chapter 5: Boolean Indexing
Introduction
Calculating boolean statistics
Getting ready
How to do it...
How it works...
There's more...
See also
Constructing multiple boolean conditions
Getting ready
How to do it...
How it works...
There's more...
See also
Filtering with boolean indexing
Getting ready
How to do it...
How it works...
There's more...
See also
Replicating boolean indexing with index selection
Getting ready
How to do it...
How it works...
There's more...
Selecting with unique and sorted indexes
Getting ready
How to do it...
How it works...
There's more...
See also
Gaining perspective on stock prices
Getting ready
How to do it...
How it works...
There's more...
See also
Translating SQL WHERE clauses
Getting ready
How to do it...
How it works...
There's more...
See also
Determining the normality of stock market returns
Getting ready
How to do it...
How it works...
There's more...
See also
Improving readability of boolean indexing with the query method
Getting ready
How to do it...
How it works...
There's more...
See also
Preserving Series with the where method
Getting ready
How to do it...
How it works...
There's more...
See also
Masking DataFrame rows
Getting ready
How to do it...
How it works...
There's more...
See also
Selecting with booleans, integer location, and labels
Getting ready
How to do it...
How it works...
There's more...
See also
Chapter 6: Index Alignment
Introduction
Examining the Index object
Getting ready
How to do it...
How it works...
There's more...
See also
Producing Cartesian products
Getting ready
How to do it...
How it works...
There's more...
See also
Exploding indexes
Getting ready
How to do it...
How it works...
There's more...
Filling values with unequal indexes
Getting ready
How to do it...
How it works...
There's more...
Appending columns from different DataFrames
Getting ready
How to do it...
How it works...
There's more...
See also
Highlighting the maximum value from each column
Getting ready
How to do it...
How it works...
There's more...
See also
Replicating idxmax with method chaining
Getting ready
How to do it...
How it works...
There's more...
Finding the most common maximum
Getting ready
How to do it...
How it works...
There's more...
Chapter 7: Grouping for Aggregation, Filtration, and Transformation
Introduction
Defining an aggregation
Getting ready
How to do it...
How it works...
There's more...
See also
Grouping and aggregating with multiple columns and functions
Getting ready
How to do it...
How it works...
There's more...
Removing the MultiIndex after grouping
Getting ready
How to do it...
How it works...
There's more...
Customizing an aggregation function
Getting ready
How to do it...
How it works...
There's more...
Customizing aggregating functions with args and *kwargs
Getting ready
How to do it...
How it works...
There's more...
See also
Examining the groupby object
Getting ready
How to do it...
How it works...
There's more...
See also
Filtering for states with a minority majority
Getting ready
How to do it...
How it works...
There's more...
See also
Transforming through a weight loss bet
Getting ready
How to do it...
How it works...
There's more...
See also
Calculating weighted mean SAT scores per state with apply
Getting ready
How to do it...
How it works...
There's more...
See also
Grouping by continuous variables
Getting ready
How to do it...
How it works...
There's more...
See also
Counting the total number of flights between cities
Getting ready
How to do it...
How it works...
There's more...
See also
Finding the longest streak of on-time flights
Getting ready
How to do it...
How it works...
There's more...
See also
Chapter 8: Restructuring Data into a Tidy Form
Introduction
Tidying variable values as column names with stack
Getting ready
How to do it...
How it works...
There's more...
See also
Tidying variable values as column names with melt
Getting ready
How to do it...
How it works...
There's more...
See also
Stacking multiple groups of variables simultaneously
Getting ready
How to do it...
How it works...
There's more...
See also
Inverting stacked data
Getting ready
How to do it...
How it works...
There's more...
See also
Unstacking after a groupby aggregation
Getting ready
How to do it...
How it works...
There's more...
See also
Replicating pivot_table with a groupby aggregation
Getting ready
How to do it...
How it works...
There's more...
Renaming axis levels for easy reshaping
Getting ready
How to do it...
How it works...
There's more...
Tidying when multiple variables are stored as column names
Getting ready...
How to do it...
How it works...
There's more...
See also
Tidying when multiple variables are stored as column values
Getting ready
How to do it...
How it works...
There's more...
See also
Tidying when two or more values are stored in the same cell
Getting ready...
How to do it..
How it works...
There's more...
Tidying when variables are stored in column names and values
Getting ready
How to do it...
How it works...
There's more...
Tidying when multiple observational units are stored in the same table
Getting ready
How to do it...
How it works...
There's more...
See also
Chapter 9: Combining Pandas Objects
Introduction
Appending new rows to DataFrames
Getting ready
How to do it...
How it works...
There's more...
Concatenating multiple DataFrames together
Getting ready
How to do it...
How it works...
There's more...
Comparing President Trump's and Obama's approval ratings
Getting ready
How to do it...
How it works...
There's more...
See also
Understanding the differences between concat, join, and merge
Getting ready
How to do it...
How it works...
There's more...
See also
Connecting to SQL databases
Getting ready
How to do it...
How it works...
There's more...
See also
Chapter 10: Time Series Analysis
Introduction
Understanding the difference between Python and pandas date tools
Getting ready
How to do it...
How it works...
There's more...
See also
Slicing time series intelligently
Getting ready
How to do it...
How it works...
There's more...
See also
Using methods that only work with a DatetimeIndex
Getting ready
How to do it...
How it works...
There's more...
See also
Counting the number of weekly crimes
Getting ready
How to do it...
How it works...
There's more...
See also
Aggregating weekly crime and traffic accidents separately
Getting ready
How to do it...
How it works...
There's more...
Measuring crime by weekday and year
Getting ready
How to do it...
How it works...
There's more...
See also
Grouping with anonymous functions with a DatetimeIndex
Getting ready
How to do it...
How it works...
There's more...
See also
Grouping by a Timestamp and another column
Getting ready
How to do it...
How it works...
There's more...
Finding the last time crime was 20% lower with merge_asof
Getting ready
How to do it...
How it works...
There's more...
Chapter 11: Visualization with Matplotlib, Pandas, and Seaborn
Introduction
Getting started with matplotlib
Getting ready
Object-oriented guide to matplotlib
How to do it...
How it works...
There's more...
See also
Visualizing data with matplotlib
Getting ready
How to do it...
How it works...
There's more...
See also
Plotting basics with pandas
Getting ready
How to do it..
How it works...
There's more...
See also
Visualizing the flights dataset
Getting ready
How to do it...
How it works...
See also
Stacking area charts to discover emerging trends
Getting ready
How to do it...
How it works...
There's more...
Understanding the differences between seaborn and pandas
Getting ready
How to do it...
How it works...
See also
Doing multivariate analysis with seaborn Grids
Getting ready
How to do it...
How it works...
There's more...
Uncovering Simpson's paradox in the diamonds dataset with seaborn
How to do it...
How it works...
There's more...
Index


๐Ÿ“œ SIMILAR VOLUMES


Pandas Cookbook: Recipes for Scientific
โœ Theodore Petrou ๐Ÿ“‚ Library ๐Ÿ“… 2017 ๐Ÿ› Packt Publishing ๐ŸŒ English

<h4>Key Features</h4><ul><li>Use the power of pandas to solve most complex scientific computing problems with ease</li><li>Leverage fast, robust data structures in pandas to gain useful insights from your data</li><li>Practical, easy to implement recipes for quick solutions to common problems in dat

Pandas Cookbook: Recipes for Scientific
โœ Theodore Petrou ๐Ÿ“‚ Library ๐Ÿ“… 2017 ๐Ÿ› Packt Publishing ๐ŸŒ English

<p><b><i>Publisher's Note: A new second edition, updated completely for pandas 1.x with additional chapters, has now been published. This edition from 2017 is outdated and is based on pandas 0.20.</i></b></p><h4>Key Features</h4><ul><li>Use the power of pandas 0.20 to solve most complex scientific c

Pandas Cookbook: Recipes for Scientific
โœ Theodore Petrou ๐Ÿ“‚ Library ๐Ÿ“… 2017 ๐Ÿ› Packt Publishing ๐ŸŒ English

Code <p><b><i>Publisher's Note: A new second edition, updated completely for pandas 1.x with additional chapters, has now been published. This edition from 2017 is outdated and is based on pandas 0.20.</i></b></p><h4>Key Features</h4><ul><li>Use the power of pandas 0.20 to solve most complex scie

Pandas 1.x Cookbook: Practical recipes f
โœ Matt Harrison, Theodore Petrou ๐Ÿ“‚ Library ๐Ÿ“… 2020 ๐Ÿ› Packt Publishing ๐ŸŒ English

Use the power of pandas to solve most complex scientific computing problems with ease. Revised for pandas 1.x. Key Features โ€ข This is the first book on pandas 1.x โ€ข Practical, easy to implement recipes for quick solutions to common problems in data using pandas โ€ข Master the fundamentals of pan