I am trying to write a function that does something similar to pandas\'s groupby().ngroups() function. The difference is that I want each subgroup count to rest
groupby().ngroups()