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


















