Topics in this subject
Pandas 2 min read Updated 4 Aug 2026

Quick Comparison Tables

Revision notes.

NumPy vs Pandas#

Aspect NumPy Pandas
Core object ndarray Series, DataFrame
Labels Positional only Labeled index & columns
Data types Homogeneous Heterogeneous per column
Missing data Limited (NaN in float) First-class (NaN, NaT, pd.NA)
Best for Numeric/matrix math, ML tensors Tabular data, EDA, cleaning
Built on C NumPy

loc vs iloc#

loc iloc
Indexes by Labels Integer position
Slice endpoint Inclusive Exclusive
Boolean masks Yes Yes
Example df.loc['a':'c'] df.iloc[0:3]

merge vs join vs concat#

merge join concat
Aligns on Columns/keys Index (default) Axis
SQL analog JOIN JOIN on index UNION / column bind
Key matching Yes Yes (index) No
Use for Key joins Quick index merge Stacking frames

flatten vs ravel#

flatten ravel
Returns Always a copy View when possible
Speed Slower (allocates) Faster
Safe to mutate Yes Careful — may affect parent

reshape vs resize#

reshape resize
Total size Must match Can change (pads/trims)
Returns View/copy (new shape) Modifies in place
Errors on mismatch Yes No

copy vs view#

View Copy
Memory Shared Independent
Created by slicing, reshape, .T fancy/bool index, .copy(), flatten
Mutation effect Affects parent Isolated
Check x.base is not None x.base is None

apply vs map#

apply map applymap/DataFrame.map
Object Series/DataFrame Series only DataFrame only
Granularity Along axis or element Element-wise Every cell
Dict input No Yes (lookup) No
Speed Slow-ish Fast for lookups Slow

groupby vs pivot_table#

groupby pivot_table
Output shape Long (grouped) Wide (cross-tab)
Aggregation Any Any (aggfunc)
Two dimensions via multi-key + unstack Native (index × columns)
Best for Flexible aggregation 2-D summary reports

stack vs unstack#

stack unstack
Direction Columns → index Index → columns
Result Taller/longer Wider
Shape More rows More columns