Data Analytics

Python Analytics - Advanced Analysis and ML

groupby, merge, pivot_table, apply/map, Plotly, Scikit-Learn (regression, classification, clustering), train/test split, metrics, Jupyter, Google Colab

20 interview questionsยท
Senior
1

What is the main difference between apply() and map() methods on a Pandas Series?

Answer

The map() method is designed to map each value in a Series to a new value using a dictionary or function, and works only on Series. In contrast, apply() is more flexible: it can apply a function element-wise on a Series or row-wise/column-wise on a DataFrame. For simple value-to-value transformations on a Series, map() is generally faster and more readable.

2

Which Pandas method should be used to aggregate data with multiple aggregation functions on different columns simultaneously?

Answer

The agg() (or aggregate()) method allows applying different aggregation functions to different columns in a single operation. It accepts a dictionary where keys are column names and values are the functions to apply. This approach is more efficient and readable than chaining multiple groupby calls with individual functions.

3

What is the difference between merge() and join() in Pandas?

Answer

merge() is a more flexible function that joins two DataFrames on specific columns using the on, left_on/right_on parameters, or indexes. join() is a DataFrame method that joins on indexes by default and is more concise for simple index-based joins. For complex joins on non-index columns, merge() is preferable as it offers more control over join columns.

4

How to create a pivot table with pivot_table() specifying multiple aggregation functions?

5

What is the purpose of transform() in a groupby() context compared to apply()?

+17 interview questions

Master Data Analytics for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free