Python for Data Science Interview Questions for Data Science
47 Python for Data Science questions with answers for data science roles — 23 easy, 21 medium, 3 hard.
About Python for Data Science
Python rounds test whether you can clean, reshape and analyse data quickly with Pandas and NumPy, and write clear, efficient code. Expect questions on data structures, groupby, merges, memory, performance and writing small functions live. Strong Python is the base for every later round, so interviewers use it to filter candidates early.
What is the difference between list, tuple, set and dict in Python?
Show answer
What is the difference between == and is?
Show answer
Difference between loc and iloc in Pandas?
Show answer
What are Python's main built-in data types?
Show answer
How do you remove duplicates from a DataFrame?
Show answer
What is the difference between a function and a method?
Show answer
What are *args and **kwargs?
Show answer
What is NumPy broadcasting?
Show answer
What is the difference between a set and a dictionary?
Show answer
Write a function to calculate RMSE without any library.
Show answer
How do list comprehensions work and why use them?
Show answer
What is the difference between a Pandas Series and a DataFrame?
Show answer
What does the axis parameter mean in NumPy and Pandas?
Show answer
What is method chaining in Pandas and why do teams use it?
Show answer
What are context managers in Python?
Show answer
Write Python code to count word frequencies in a text and print the top 5 words.
Show answer
Write a Python function to flatten a nested list of any depth.
Show answer
Pandas: convert wide monthly columns into a long format table.
Show answer
Tell me about a time you improved messy code written by someone else.
Show answer
What are type hints in Python and why do data teams use them?
Show answer
What are dataclasses in Python and why are they useful in data projects?
Show answer
Write Python code to group a list of order dictionaries by city and sum the amounts without Pandas.
Show answer
Difference between a shallow copy and a deep copy?
Show answer
How do you pivot data in Pandas?
Show answer
What are decorators in Python?
Show answer
Why are NumPy arrays faster than Python lists?
Show answer
What is the Global Interpreter Lock (GIL)?
Show answer
What are lambda functions and where are they useful?
Show answer
Pandas: find the top 3 products by revenue in each region.
Show answer
Pandas: merge vs join vs concat?
Show answer
How do you use groupby with multiple aggregations?
Show answer
How do you profile and speed up slow Python code?
Show answer
What is a generator and when would you use one?
Show answer
What is the difference between iterators and iterables in Python?
Show answer
What is the difference between apply, map and applymap in Pandas?
Show answer
You assign values to a filtered DataFrame and Pandas shows a SettingWithCopyWarning. What is going on and how do you fix it?
Show answer
Write Pandas code to read a large CSV in chunks and compute total sales per city.
Show answer
Pandas: compute a 7-day rolling average of daily sales for each store.
Show answer
A 10 million row DataFrame with a city column is using too much memory. How can the category dtype help?
Show answer
How do you handle dates and time zones in Pandas?
Show answer
Your notebook runs on your laptop but fails on a colleague's machine. How do you make the work reproducible?
Show answer
A Pandas merge suddenly returns many more rows than the left table had. What happened?
Show answer
Pandas: find customers whose monthly spend increased for three consecutive months.
Show answer
How would you optimise a slow Pandas pipeline on a 5 GB file?
Show answer
Your feature computation on millions of rows uses only one CPU core. Would you use threads or processes to speed it up?
Show answer
How would you structure a data science codebase so notebooks do not become unmaintainable?
Show answer
Frequently asked questions
How important is Python for Data Science in Data Science interviews?
Python rounds test whether you can clean, reshape and analyse data quickly with Pandas and NumPy, and write clear, efficient code. Expect questions on data structures, groupby, merges, memory, performance and writing small functions live. Strong Python is the base for every later round, so interviewers use it to filter candidates early.
How should I use the Python for Data Science sheet?
Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.