code: def __init__(self, group, name=""):
      super(self.__class__, self).__init__(group, name=name)
  
      idx = (np.nonzero(np.diff(group))[0] + 1).tolist()
      self.groupidx = lzip([0] + idx, idx + [len(group)])
  
imports: from statsmodels.compat.python import lrange, lzip
  import numpy
  import pandas
  import statsmodels.tools.data
  from pandas import Index, MultiIndex
label_desc: Use image node_id 1 to create a new GroupSorted object from inherited base classes: Group with example: obj = GroupSorted(group, name)