Python Q&A: Top 10 Data Science Interview Questions

The Top 10 Python Q&A 1. What is the difference between a List and a Tuple? List: Mutable (can be changed), uses [], slower for large datasets. Tuple: Immutable (cannot be changed), uses (), faster and more memory-efficient. Analyst Tip: Use tuples for fixed data like coordinates or "read-only" categories. 2. How do you handle missing values in Pandas? You typically use .isnull() to find them, and then: .dropna(): To remove rows/columns with missing data. .fillna(value): To replace NaNs with a specific value, mean, or median. 3. What is the difference between .loc and .iloc? .loc: Label-based indexing (uses column/row names). .iloc: Integer-based indexing (uses numerical positions). 4. When should you use a Lambda function? Lambda functions are anonymous, one-line functions. They are perfect for quick data transformations inside a .apply() method: df['price_usd'] = df['price_inr'].apply(lambda x: x / 83) 5. Why is NumPy faster than Python Lists? NumPy arrays use contiguous memory and homogeneous data types (all elements are the same type), allowing for "vectorized" operations that avoid the overhead of Python loops. 6. What is the difference between merge() and concat()? merge(): SQL-style joining based on specific keys (Left, Right, Inner, Outer). concat(): Stacking DataFrames on top of each other or side-by-side. 7. How do you remove duplicates in a DataFrame? Use df.drop_duplicates(). You can specify subset=['column_name'] to check for duplicates in specific columns only. 8. Explain the difference between map(), apply(), and applymap(). map(): Works on a Series (element-wise). apply(): Works on both Series and DataFrames (row or column-wise). applymap(): Works on the entire DataFrame (element-wise). 9. What is a "SettingWithCopyWarning" in Pandas? This happens when you try to modify a "view" of a DataFrame instead of the original. To fix it, use .loc for assignment or create an explicit copy using .copy(). 10. Which library would you use for interactive visualizations in 2026? While Matplotlib and Seaborn are great for static charts, Plotly or Polars-native plotting are the go-to choices for interactive, web-ready dashboards. #python #jobinterview #datascience #dataanalystquestions

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories