liveBook · Manning

Chapter 24: Exploring data

What you will learn in chapter 24 of The Quick Python Book, Fourth Edition

The introduction previews a shift from getting and cleaning data to manipulating and exploring it with Python.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction previews a shift from getting and cleaning data to manipulating and exploring it with Python.

24.1 Python tools for data exploration

The section introduces pandas and Matplotlib as tools the chapter will briefly explore for working with data in Jupyter.

24.1.1 Python’s advantages for exploring data

This subsection explains why Python is useful for exploring data despite not always having the fastest raw performance.

Key terms: raw performance, NumPy, readability, accessibility, developer time

24.1.2 Python can be better than a spreadsheet

This section explains why Python can be more flexible than spreadsheets for manipulating large or complex datasets.

Key terms: row limit, two-dimensional grids, lists, tuples, sets, dictionaries

24.2 Python and pandas

This section explains why pandas is useful for repetitive data-handling work in Python.

Key terms: pandas, datasets, cleaning data, filtering data

24.2.1 Why you might want to use pandas

This section explains why pandas can make tabular data work easier and why its learning curve and fit for the task matter.

Key terms: pandas, tabular or relational data, standard framework

24.2.2 Installing pandas

This subsection explains how to get pandas and its plotting companion installed and how to prepare a Jupyter notebook to use them.

Key terms: Colaboratory, pandas, matplotlib, numpy, pip, Jupyter virtual environment, Jupyter “magic” function, pd

24.2.3 Data frames

This section introduces pandas data frames as in-memory grids and shows how their columns and values are easier to work with than a list of lists.

Key terms: data frame, list of lists, row, column, column names, select columns by name, double brackets, subset, list comprehension, add()

24.3 Data cleaning

The section introduces upcoming examples of cleaning data with pandas and comparing those operations with plain Python.

24.3.1 Loading and saving data with pandas

This section shows how pandas loads data into data frames, standardizes missing values while loading, and saves data frames in different formats.

Key terms: read_json(), read_csv(), data frame, SQLAlchemy, na_values, NaN, Missing, JSON object

24.3.2 Data cleaning with a data frame

Shows how pandas data frames simplify cleaning a temperature CSV by loading only useful columns and converting a percentage column from text to numeric values.

Key terms: data frame, range(), names parameter, NaN, strip(), replace(), div(), chaining, percentage, fraction

24.4 Data aggregation and manipulation

Introduces the upcoming examples of merging, aggregating, grouping, and filtering data with pandas.

24.4.1 Merging data frames

This subsection shows how pandas merges related data frames and names the kinds of joins it supports.

Key terms: merge function, data frame, relational database join, one-to-one, one-to-many, many-to-many, right and left joins

24.4.2 Selecting data

This subsection shows how pandas selects data-frame rows by using a condition as an index.

Key terms: data frame, select, filter, index

24.4.3 Grouping and aggregation

This section shows how to summarize pandas columns, select rows using a summary value, and aggregate data by groups.

Key terms: column methods, median, selection operation, groupby, aggregate, sum

24.5 Plotting data

Shows how to create simple plots directly from a pandas data frame in a Jupyter notebook.

Key terms: pandas, matplotlib, data frame, inline plotting, .plot.bar(), .plot.line()

24.6 Why you might not want to use pandas

This section explains why pandas is useful but not always the best tool for a data task.

Key terms: pandas, plain old Python, production situations, large datasets

24.7 Summary

Concepts explained in this chapter

← Chapter 23: Saving data

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.