Pandas GroupBy | 28/100 Days of Python Algo Trading

Congratulations on reaching this stage!

If you’re here, it means you’re truly dedicated to mastering Python. Directly below, you’ll find a quiz designed to help you reinforce what you’ve just learned. This isn’t just about recalling facts; it’s about deeply understanding the concepts. Take a moment to answer the questions and see how well you can apply the knowledge from the video. You’re doing great—every question you tackle brings you one step closer to becoming a Python expert!

Day 28 :Pandas GroupBy

1. What does the GroupBy operation in Pandas allow you to do?
2. Which of the following is the correct way to group a DataFrame by a column named 'Sector'?
3. What will the following code return: df.groupby('Category')['Sales'].sum()?
4. How can you apply a custom function to each group in a GroupBy object?
5. What is the purpose of the .agg() method in GroupBy?
6. Which of the following statements is true about GroupBy operations?
7. How do you reset the index after a GroupBy operation?
8. Which of the following methods can be used to transform group data into another DataFrame?
9. What does the .size() method return when used on a GroupBy object?
10. Which of the following can be passed to the .agg() method?
11. What is the correct syntax to group by multiple columns?
12. How can you group data by a specific column and calculate the mean of another column?
13. What will the following code do: df.groupby('Category').filter(lambda x: x['Sales'].mean() > 200)?
14. Which method would you use to apply multiple aggregation functions at once?
15. How can you iterate over groups in a GroupBy object?
16. What will the following code do: df.groupby('Category').ngroup()?
17. Which of the following methods is used to get the first value in each group?
18. What does the .cumcount() method do in a GroupBy operation?
19. How can you use GroupBy to rank data within each group?
20. Which of the following statements best describes the use of the .apply() method with GroupBy?