liveBook · Manning

Pandas

As explained in Pandas Workout: 200 exercises to make you a stronger data analyst

An open-source Python library for data analysis and manipulation, including labeled tabular data structures.

pandas is used to turn files and survey-sized tables into questions you can answer. Its core workflow is practical: load data, shape indexes and columns so they reflect the problem, compute results, and inspect what comes back. section 8.4 section 13.4

A Series is a labeled sequence. Labels are not decoration: when two Series are combined, pandas matches values by index rather than by physical position. Operations return new Series, preserving the relevant index. section 1.7

Common analytical moves include:

  • Read CSV, JSON, and HTML-table inputs, controlling parsing, column selection, and dtypes when needed. section 3.24
  • Use vectorized arithmetic and comparisons; scalar operations broadcast across a Series, while boolean results can act as masks. section 1.7
  • Select by labels with .loc or positions with .iloc, then summarize slices with methods such as mean. section 1.3
  • Clean, filter, group, join, reshape, and compare data frames to answer larger questions. section 8.4
  • Work with text through the str accessor and visualize data through pandas’ simplified Matplotlib API. section 9.13 section 11.21

Adjusting a month-indexed score Series

Generate ten scores, assign month labels, and compute their mean. If the goal is an average of 80, calculate 80 minus the current mean, then add that scalar to the Series. Broadcasting adjusts every score; using the mean first connects a scalar calculation back to labeled data. section 1.3 section 1.7

Analyzing developer surveys

A large survey can be made easier to navigate by converting flat dotted column names into a MultiIndex. From there, select a column or group, count values, filter respondents, group by country, calculate proportions, join another survey, and build pivot tables for compensation comparisons. section 8.2

py_filename = '../data/2020_sharing_data_outside.csv'
py_df = pd.read_csv(py_filename)

Load a Python survey CSV into a data frame; larger inputs may require dtype or memory decisions before analysis. section 8.2

The transferable habit is to reason about shape and labels before chaining methods: decide whether the operation should produce a scalar, Series, or data frame, then verify the returned object and extend the analysis with another question. section 1.7 section 13.4

How Pandas Workout: 200 exercises to make you a stronger data analyst covers it

How deep it goes
Explains Series indexing, alignment, broadcasting, and substantial data-frame analysis without cataloging all pandas capabilities.
Examples
Uses monthly test scores, New York City taxi passenger counts, and Python and Stack Overflow survey data.
What it assumes
Assumes Python and introduces Series construction while relying on NumPy for random-number generation.
What you can do after
Apply it via pandas to load, clean, join, analyze, and visualize data frames and Series.
How it connects
Connects pandas with NumPy, CSV and JSON files, MultiIndex, groupby, pivot tables, Matplotlib, Seaborn, and string methods.

Also explained in

Compare how 11 books explain pandas →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pandas Workout: 200 exercises to make you a stronger data analyst. The section links point to the parts of the book it draws on.