OpenEDG PCAD study materials
OpenEDG PCAD study resources

OpenEDG PCAD: Data Exploration and Analysis with Pandas and NumPy

OpenEDG PCAD · Work through your exam, one topic at a time.

All guide sections

Data Exploration and Analysis with Pandas and NumPy

What this domain tests

This domain covers exploratory analysis in pandas and NumPy: selecting and filtering, grouping and aggregating, reshaping, and vectorized computation. The exam checks whether you can move from a question to a correct, reproducible summary.

Core rules

  • loc is label-based and iloc is position-based; use loc for boolean masks and column names.
  • Boolean masks combine with &, |, and ~ and need parentheses: df[(df.a > 0) & (df.b == 'x')].
  • groupby(...).agg(...) produces one row per key; transform returns an aligned column; pivot_table reshapes long to wide.
  • NumPy operations are vectorized: arr * 2, np.where(cond, a, b), and broadcasting across shapes. axis=0 reduces rows, axis=1 reduces columns.
  • Always check .shape, .dtypes, and .head() after each transformation.

Worked example

You have sales with region, revenue, and units. To find each region's mean revenue and its share of total revenue, run g = sales.groupby('region', as_index=False).agg(mean_rev=('revenue', 'mean'), n=('revenue', 'size')), then g['share'] = g['mean_rev'] * g['n'] / sales['revenue'].sum(). Reasoning: the weighted share must use total revenue per region, which is mean times count, not the mean alone; as_index=False keeps region as a column for later merges.

Traps that cost marks

  • Confusing axis=0 and axis=1 in NumPy reductions.
  • Using and or or instead of & or | on Series, which raises an ambiguity error.
  • Expecting groupby to keep NaN keys by default; dropna=True hides them.
  • Forgetting that NumPy integer arrays overflow silently at fixed widths.
  • Chaining many operations without intermediate checks, so a dtype change goes unnoticed.