@Substitution(name='<STR_LIT>')<EOL><INDENT>@Substitution(see_also=_common_see_also)<EOL>def tail(self, n=<NUM_LIT:5>):<DEDENT>
self._reset_group_selection()<EOL>mask = self._cumcount_array(ascending=False) < n<EOL>return self._selected_obj[mask]<EOL>
Return last n rows of each group.

Essentially equivalent to ``.apply(lambda x: x.tail(n))``,
except ignores as_index flag.
%(see_also)s
Examples
--------

>>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]],
                      columns=['A', 'B'])
>>> df.groupby('A').tail(1)
   A  B
1  a  2
3  b  2
>>> df.groupby('A').head(1)
   A  B
0  a  1
2  b  1