Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
Python Data Analysis Fourth Edition Master Python Analytics with Machine Learning, Deep Learning, GenAI, LLMs, and Data Engineering Avinash Navlani Cornellius Yudha Wijaya
Page
3
Python Data Analysis Fourth edition Copyright © 2026 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. This book was written by the authors. Generative AI tools were only used to assist with phrasing and diagram drafts, and all the technical content and code were created, verified, and tested by the authors and Packt’s editorial team. Packt does not accept AI-generated content that replaces expert authorship. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors nor Packt Publishing, or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Portfolio Director: Sunith Shetty Relationship Lead: Sanjana Gupta Project Manager: Shashank Desai Content Engineer: Ayushi Bulani Technical Editor: Seemanjay Ameriya Indexer: Pratik Shirodkar Production Designer: Ganesh Bhadwalkar Growth Lead: Shruthi Shetty First published: October 2014 Second Edition: March 2017 Third Edition: May 2021 Fourth edition: June 2026 Production reference: 1170626 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul’s Square Birmingham B3 1RB, UK ISBN 978-1-80602-287-8 www.packtpub.com
Page
4
Contributors About the authors Cornellius Yudha Wijaya has over eight years of experience in data science, machine learning, and artificial intelligence. He currently works as a data scientist manager, where he leads AI initiatives, manages team members, and helps drive the development of practical data and AI solutions. Over the course of his career, he has worked across data science, AI product development, and technical edu- cation, with experience in building machine learning systems, supporting business decision-making, and making advanced analytics more usable in real-world settings. He has also written extensively on data science, Python, machine learning, and generative AI, with a strong focus on practical learning and applied problem-solving. I am deeply grateful to my family for their love, patience, and understanding while I worked on this book. Thank you for giving me the time and space to see it through. Avinash Navlani, PhD in Data Science, is a senior data scientist, researcher, and educator with 14 years of experience in data science, including 9 years in industry, 4 years in academia, and 1 year in research. He has developed machine learning models, optimization solutions, NLP systems, scalable data pipelines, and cloud-based MLOps platforms across healthcare, retail, finance, oil & gas, and manufacturing. His expertise includes Python, PySpark, Airflow, Databricks, Azure ML, MLflow, and Data Engineering. A former lecturer and speaker, he is passionate about applying analytics to solve real-world problems. This book is dedicated to learners, researchers, and professionals who believe in the power of data to create meaningful change now.
Page
5
About the reviewer Praveen Gupta Sanka is a seasoned Data Scientist with over a decade of experience in data science and analytics at leading technology companies, where he has tackled complex business challenges and advanced data-driven decision making. His expertise spans machine learning, statistics, and scalable analytics, with contributions to high-impact products and systems across advertising, payments, and privacy. He has applied rigorous analytical methods to real-world, high-stakes decision systems. Beyond industry, he has contributed to the broader data science community through mentoring, peer review- ing, and service in professional organizations such as IEEE and the American Statistical Association.
Page
6
Table of Contents Preface xix Free benefits with your book xxiv Part 1: Foundations for Data Analysis 1 Chapter 1: Getting Started with Python Libraries 3 Navigating the landscape of data analysis 4 Exploring libraries for data analysis • 4 Data analysis process methodology • 5 Knowledge discovery from data • 5 Sample, explore, modify, model, and assess • 6 CRoss-InduStry Process for Data Mining • 7 Standard process of data analysis • 9 Comparing data analysis, data science and data engineering 10 Data analysis • 11 Data science • 11 Data engineering • 11 Job roles in the data science domain • 12 Roles of data analyst, data scientist and data engineer • 12 Roles of ML engineer and NLP engineer • 15 A quick look at MLOps • 16 Installing Python 3 16 Python installation and setup on Windows • 17 Python installation and setup on Linux • 17 Python installation and setup on mac OS X with a GUI installer • 17 Python installation and setup on Mac OS X with brew • 18
Page
7
(This page has no text content)
Page
8
(This page has no text content)
Page
9
(This page has no text content)
Page
10
(This page has no text content)
Page
11
Table of Contentsx KDE plots • 210 Box plots • 211 Heatmaps • 211 Violin plots • 213 Count plots • 214 Joint plots • 215 Pair plots • 217 Building interactive and advanced visualizations with plotly 219 Basic plotly charts • 219 Scatter plot • 220 Line plot • 221 Bar plot • 222 Histogram • 223 Box plot • 224 Gantt chart using plotly • 225 Annotations using plotly • 226 Subplots using plotly • 228 Multiple layer plots • 232 Custom buttons • 233 Dropdowns • 235 Sliders • 238 Building analytical dashboards with the Dash framework 240 First interactive plot in Dash • 241 Dash DataTable • 243 Multi-Page layout in Dash • 244 Real-Time updates • 247 Summary 249 Chapter 6: Retrieving, Processing, and Storing Data 251 Reading and writing data from CSV and Excel 252 Reading and writing CSV files with Pandas • 253 Reading and writing data to Excel • 253 Reading and writing data from JSON and HTML tables 254 Reading and writing data from JSON • 254 Reading and writing data from HTML tables • 255 Reading and writing data from HDF5 and Parquet 256 Reading and writing data from HDF5 • 256 Reading and writing data from Parquet • 257
Page
12
(This page has no text content)
Page
13
(This page has no text content)
Page
14
(This page has no text content)
Page
15
(This page has no text content)
Page
16
(This page has no text content)
Page
17
(This page has no text content)
Page
18
(This page has no text content)
Page
19
(This page has no text content)
Page
20
Preface Data analysis has become one of the most important practical skills in modern workflows. Organi- zations collect more data than ever, but raw data on its own does not create value. Value comes from knowing how to explore, clean, model, interpret, and communicate data results in ways that support real decisions. Python has become one of the most widely used languages for this work because it combines a simple programming model with a rich ecosystem for statistics, visualization, machine learning, and large-scale data processing. This book is written to help you build that practical capa- bility in a structured and progressive way. Rather than treating data analysis as a collection of disconnected tools, this book approaches it as an end-to-end workflow. We begin with the foundations that every practitioner needs: understanding the data analysis process, setting up a productive Python environment, and building fluency with essential libraries such as NumPy and pandas, along with the statistical and linear algebra concepts that support analytical thinking. These topics provide the base needed not only to write code, but also to reason correctly about data, transformations, and model behavior. From there, the book moves into the practical work of exploratory analysis and data preparation. You will learn how to visualize data effectively, retrieve it from a variety of sources, clean messy data- sets, engineer useful features, and work with time series data. This stage reflects a simple reality of real-world analytics: before we can build useful models, we need to understand the data and make it usable. Strong analytical work depends as much on careful preparation and exploration as it does on modeling itself. Once these foundations are in place, the book shifts into machine learning. We cover supervised learn- ing, unsupervised learning, ensemble methods, and neural networks to show how different modeling approaches fit various business and analytical problems. The goal is not only to show how models are trained but also to help you understand how to evaluate, compare, and apply them responsibly in practice. By placing these chapters after the earlier chapters on statistics, data cleaning, and feature en- gineering, the book emphasizes that good machine learning depends on a strong analytical foundation. In the final part of the book, the scope expands to several of the most relevant applied areas in modern Python-based analytics. We examine textual data, image data, large language models and generative AI, parallel computing with Dask, Modin, and Ray, and large-scale analytics with PySpark. These chapters reflect how the field has evolved. Data analysis today is no longer limited to spreadsheets or structured tables. Practitioners increasingly work across multiple data types, larger computational environments, and new AI-driven workflows. This book is designed to help you build enough breadth to understand that wider landscape while remaining grounded in practical Python implementation.
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A hands-on, end-to-end tour of Python analytics that carries you from NumPy and Pandas fundamentals through statistics, visualization, and databases into machine learning, deep learning, and modern GenAI/LLM workflows. Best suited to aspiring or practicing data analysts and data scientists who want one coherent path from data wrangling to deployed models.
【Book Arc】
- **Opening (~0%–10%)**: Frames the data-science landscape — roles, required skills, and tooling — then installs the working foundation: Jupyter/Anaconda setup and the NumPy array and Pandas DataFrame structures that underpin every later chapter.
- **Early (~10%–30%)**: Builds core manipulation and analysis skills: array reshaping/stacking/splitting, DataFrame selection, filtering, and datetime handling, followed by descriptive statistics, skewness/kurtosis, probability, Bayes' theorem, and linear algebra with NumPy.
- **Early–Middle (~30%–50%)**: Turns data into insight through visualization — Matplotlib and Seaborn chart types, subplots, and interactive Dash dashboards with tabs, callbacks, and real-time updates.
- **Middle (~50%–60%)**: Covers the data plumbing layer: SQLite/SQL connectivity, REST and GraphQL API extraction with requests/httpx, and the retrieve-process-store pipeline.
- **Late (~60%–85%)**: Moves into modeling: supervised learning, then unsupervised techniques (dimensionality reduction, K-Means, hierarchical and DBSCAN clustering, anomaly detection with Isolation Forest and LOF) and ensemble methods (bagging, random forests, boosting, stacking, XGBoost).
- **Ending (~85%–100%)**: Extends into deep learning with TensorFlow/Keras/PyTorch and the GenAI/LLM frontier, connecting classical analytics to contemporary NLP and image applications.
【Key Takeaways】
- **NumPy and Pandas are the load-bearing walls** (Opening): Arrays and DataFrames enable vectorized computation, reshaping, boolean filtering, and datetime feature extraction — the operations every later chapter assumes you can perform fluently.
- **Statistics is treated as a decision toolkit, not theory** (Early): Descriptive summaries, skewness/kurtosis, and Bayes' theorem are tied to concrete uses in healthcare, spam filtering, finance, and marketing, so you learn when to reach for each.
- **Visualization spans static to interactive** (Early–Middle): The book progresses from Matplotlib/Seaborn charts to Dash dashboards with tab layouts, callbacks, and interval-driven real-time updates for sensor and sales data.
- **Data retrieval is a first-class skill** (Middle): SQLite via the standard library, SQL queries, and API consumption through requests/httpx are presented as the practical bridge between raw sources and analysis-ready tables.
- **Unsupervised learning covers the full triad** (Late): Dimensionality reduction, clustering (K-Means, hierarchical, DBSCAN), and anomaly detection (Isolation Forest, LOF) each come with evaluation methods, not just algorithms.
- **Ensembles are the accuracy workhorse** (Late): Bagging, random forests, extra trees, AdaBoost, gradient boosting, voting, stacking, and XGBoost are compared so you can choose by bias-variance trade-off rather than habit.
- **The book deliberately reaches the GenAI era** (Ending): Deep learning frameworks and LLM/GenAI material position classical analytics within modern NLP and image workflows — a notable scope choice for a data-analysis title.
【Reading Tips】
- **Deep-read Chapters 2–3 (NumPy/Pandas and statistics)**: Everything downstream assumes this fluency; skimming here creates friction in every modeling chapter.
- **Skim the environment setup and role descriptions** in the opening chapter unless you are new to Jupyter/Anaconda — the value is concentrated in the library chapters.
- **Treat the visualization and Dash chapters as a reference**: Read the chart-type overview once, then return when you need a specific plot or dashboard pattern.
- **Pair each algorithm chapter with its evaluation subsection**: The book consistently pairs methods with metrics (clustering evaluation, anomaly detection MV/EM curves) — that pairing is the real takeaway.
- **Use the late chapters to plan, not to master**: Deep learning and GenAI coverage is broad; pick one framework and one LLM use case to pursue hands-on.
【Coverage Limits】
This guide is synthesized from stratified excerpts covering roughly the first half of the book in detail, with later chapters (unsupervised learning, ensembles, deep learning, GenAI/LLMs) visible mainly through the table of contents and brief mentions. Specific code, datasets, and evaluation results from the later modeling chapters are not covered by the excerpts.
Passage locations
Excerpt 1
ask of performing intensive data visualization on machines. A data scientist must be a jack of all trades and wear multiple hats, including data analyst, sta...
View in text
Excerpt 2
g. This is different from normal Python lists, where the + operator concatenates two lists instead of adding their elements. Therefore, NumPy makes numerical...
View in text
Excerpt 3
_balance vector of size 5000 with zero values and assigned the first value to 500. After that, we generated the values between 0 and 9 with a 0.5 probability...
View in text
Excerpt 4
ict(label="Actual Sales", method="update", args=[{"visible":[True, False]}]), # Actual dict(label="Forecasted Sales", method="update", args=[{"visible":[Fals...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay