18. Interview Questions and Answers
18.2 pandas Core
Q4. Series vs DataFrame?
A Series is a single column with an index. A DataFrame is a table of aligned columns. df["amount"] returns a Series; df[["city","amount"]] returns a DataFrame.
Q5. loc vs iloc?
loc selects by label; iloc by integer position. Example: df.loc[df["city"]=="Pune", "amount"] vs df.iloc[0:5, 0:3].
Q6. How do you filter rows with multiple conditions?
Boolean masks combined with & | ~, each condition in parentheses: df[(df["city"]=="Pune") & (df["status"]=="Delivered")].
Q7. Explain groupby.
Split rows into groups, apply aggregations (sum, mean, count, nunique), combine results. Named aggregations keep clear column names for reports.
Q8. concat vs merge?
concat stacks objects along an axis (usually rows). merge joins on keys like SQL join / Excel XLOOKUP. I check duplicate keys and row counts after merge.
Q9. How do you handle missing values?
Depends on the column: drop rows if the key is missing; fill category with Unknown only if documented; use median for some numeric sensor glitches; never silent dropna() on the whole frame without logging counts.
Q10. How do you parse Indian dates?
pd.to_datetime(series, dayfirst=True) or an explicit format=. For class work I localise to Asia/Kolkata (IST) when time of day matters.