Q1
Why is vectorized NumPy/Pandas arithmetic 50x–100x faster than .iterrows() when processing 1 million rows?
.iterrows() converts each row into a fresh Python Series with dynamic Python loop dispatch on every iteration. Vectorized column operations execute tight contiguous C/SIMD loops without Python interpreter overhead.
Q2
What hidden trap happens when merging two DataFrames (pd.merge) that share duplicate non-unique keys?
If left has 3 rows for cust_id=10 and right has 4 rows, pd.merge silently emits a 3 x 4 = 12 row Cartesian explosion—inflating SUM(revenue) wildly! Validate key uniqueness via validate='many_to_one'.
Q3
Why does df['amount'].sum() ignore NaN safely while df['col1'] + df['col2'] turns valid numbers into NaN?
Reduction methods like .sum() default to skipna=True, whereas binary element-wise operators (+, -) propagate NaN unless you write df['col1'].add(df['col2'], fill_value=0).
Q4
How does np.nan == np.nan evaluate in Python/Pandas—and why do groupby() operations drop NaN groups by default?
Under IEEE-754 floating point rules, NaN != NaN is always true (float('nan') == float('nan') is False). And df.groupby('region') drops NaN keys unless dropna=False is passed—hiding missing-region revenue.
Q5
Why should categorical string columns with low cardinality (e.g., city, status across 2M rows) be cast to category dtype?
Storing repeated Python string objects per row consumes massive RAM; Pandas category stores integer codes pointing to a tiny lookup array, cutting memory up to 90% and speeding up groupby.
Q6
What breaks when reading CSV phone numbers or postal codes (00124) with pd.read_csv() defaults?
Pandas auto-infers numeric types, stripping leading zeroes (124) or turning 16-digit IDs into imprecise float64 scientific notation. Force dtype={'pincode': str, 'account_id': str} at load time.
Q7
How do groupby().transform('mean') vs groupby().agg('mean') behave differently?
.agg() collapses each group down to one summary row (smaller index), whereas .transform() broadcasts the group summary back to EVERY original row's index—ideal for computing sales - group_avg directly.
Q8
Why can pd.to_datetime('04/05/2026') silently swap day and month across Indian vs US exports?
Ambiguous DD/MM/YYYY vs MM/DD/YYYY strings parse inconsistently unless you pass explicit format='%d/%m/%Y' or dayfirst=True.
Q9
When memory-mapping huge JSON/CSV analytics files, how does chunksize= in read_csv() prevent RAM crashes?
Reading pd.read_csv(path, chunksize=100_000) streams manageable slices iteratively so you can filter/aggregate each chunk and concatenate tiny results without loading 8 GB into memory at once.
Q10
Why does df.sort_values() preserve or break index numbers, and when should you chain .reset_index(drop=True)?
Sorting keeps original row index labels attached, which causes weird alignment bugs when assigning unindexed NumPy arrays or slicing with .loc vs .iloc. Resetting with drop=True avoids adding an unwanted 'index' column.