InterviewStack.io LogoInterviewStack.io

Python Programming & ML Libraries Questions

Python programming language fundamentals (syntax, data structures, control flow, error handling) with practical usage of machine learning libraries such as NumPy, pandas, scikit-learn, TensorFlow, and PyTorch for data manipulation, model development, training, evaluation, and lightweight ML tasks.

MediumTechnical
22 practiced
Given a pandas `merge` that is unexpectedly slow, outline a step-by-step debugging checklist to speed it up: inspect dtypes, index usage, join keys cardinality, sorting, and alternatives such as using database joins or category encoding. Include practical code snippets to implement fixes.
EasyTechnical
18 practiced
Explain differences in Python between list, tuple, set, and dict in terms of mutability, typical use cases, and average time complexity for membership test, insertion, and deletion. For each type give a one-sentence example where a data scientist would prefer it during preprocessing or feature engineering.
MediumTechnical
22 practiced
Implement a custom scikit-learn Transformer class `LogTransformer` with `fit` and `transform` that takes a list of feature names and applies `log1p` after handling zeros and negatives robustly (e.g., shift). Show how to integrate it into a `Pipeline` and ensure `get_params` and `set_params` behave correctly.
HardTechnical
22 practiced
Implement a simple data loader in PyTorch `Dataset`/`DataLoader` that reads from multiple CSV files lazily, parses and tokenizes text columns, and batches examples. Make sure it supports shuffling and deterministic behavior when given a seed.
MediumTechnical
25 practiced
You have a pandas groupby transform that runs slowly on a DataFrame with 10M rows. Describe 5 practical optimizations to speed up groupby aggregations or replace them with faster approaches, considering dtypes, indexing, chunking, categorical encoding, and third-party tools.

Unlock Full Question Bank

Get access to hundreds of Python Programming & ML Libraries interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.