<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def head(self, n=5):
 """ Return first n rows of each group. Essentially equivalent to ``.apply(lambda x: x.head(n))``, except ignores as_index flag. %(see_also)s Examples -------- columns=['A', 'B']) A B 0 1 2 2 5 6 A B 0 1 2 2 5 6 """

        self._reset_group_selection()
        mask = self._cumcount_array() < n
        return self._selected_obj[mask]