$ show PacktPublishing/Pandas-Cookbook-Second-Edition
The repository is the official code bundle for the book 'Pandas Cookbook - Second Edition' by Packt Publishing. It contains Jupyter notebooks for each chapter, demonstrating pandas functionality for data manipulation, analysis, and visualization. The notebooks use a variety of real-world datasets to illustrate concepts such as data cleaning, filtering, grouping, reshaping, and time series analysis. Additionally, there are two demo directories that provide a reusable module for loading and cleaning Kaggle survey data, along with tests. The repository serves as an educational resource for learning pandas through practical examples.
The LLM identified 2 files worth highlighting for reuse:
Provides two functions: `load_raw` for extracting a CSV from a zip file and skipping the header, and `tweak_kag` for applying a series of transformations to the Kaggle survey data (gender normalization, age slicing, country binning, etc.). This component is isolated, depends only on pandas and zipfile, and can be reused in other projects with minimal adaptation by modifying the transformation steps.
The notebook defines several reusable utility functions for pandas groupby operations, including `flatten_cols` to flatten multi-index columns after aggregation, and `check_minority` for custom group filtering. It also demonstrates patterns for named aggregation, within-group transformation, and using apply for complex group operations. These functions are self-contained and can be extracted into a utility module for reuse in other data analysis projects.