liveBook · Manning

Data frame

As explained in Statistics Every Programmer Needs

A data frame is a tabular data structure organized into labeled rows and columns that may hold different types of values.

A data frame is a two-dimensional, labeled structure organized like a database table or spreadsheet. Its rows represent observations, while its columns represent variables that can use different data types. section 3.3.3 section 14.3

Use a data frame to:

  • Import selected columns from a CSV file while reducing memory use and speeding data loading. section 6.2
  • Inspect structure with info(), preview observations with head() and tail(), and summarize numeric columns with describe(). section 7.2.2 section 14.3
  • Create, copy, augment, group, and count variables for exploratory analysis. section 12.3.1 section 12.3.2
  • Represent contingency tables whose labeled rows and columns support indexed lookups and conditional-probability calculations. section 3.3.3

Inspecting a manufacturing data frame

A pistons data frame stores 200 diameter measurements across 40 samples. Calling info() verifies two columns, their data types, and the absence of null values; describe() summarizes count, mean, standard deviation, quartiles, and range. section 14.3

>>> import pandas as pd
>>> nfl_pbp = pd.read_csv('nfl_pbp.csv',
>>>                    usecols = ['QUARTER', 
>>>                               'DOWN', 
>>>                               'TO_GO', 
>>>                               'OFFENSIVE_TEAM_VENUE',
>>>                               'SCORE_DIFFERENTIAL', 
>>>                               'PLAY_TYPE', 
>>>                               'YARDS_GAINED'])

A focused CSV import creates an NFL play-by-play data frame containing only variables needed for fourth-down prediction. section 6.2

How Statistics Every Programmer Needs covers it

How deep it goes
Explains construction, copying, assignment, grouping, inspection, indexing, and summary statistics without descending into pandas internals.
Examples
Uses NFL play data, stock prices, simulated distributions, piston measurements, and diagnostic-test contingency tables.
What it assumes
Assumes basic Python and pandas familiarity while teaching table construction, labeled indexing, data inspection, and grouped counting.
What you can do after
Apply it via pandas to load, inspect, reshape, group, summarize, and index labeled tabular data.
How it connects
Connects pandas with CSV files, NumPy, Matplotlib, decision trees, random forests, conditional probability, time series models, and control charts.

Also explained in

Compare how 19 books explain data frame →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.