def cardinal_groupby(self):
if self._cardinal:<EOL><INDENT>g = self.network(fig=False)<EOL>cardinal_indexes = self[self._cardinal].index.values<EOL>selfs = {}<EOL>cls = self.__class__<EOL>for cardinal_index in cardinal_indexes:<EOL><INDENT>kwargs = {self._cardinal: self[self._cardinal].ix[[cardinal_index]]}<EOL>for parent, child in nx.bfs_edges(g):<EOL><INDENT>if child in kwargs:<EOL><INDENT>continue<EOL><DEDENT>typ = g.edge_types[(parent, child)]<EOL>if self._cardinal in self[child].columns and hasattr(self[child], '<STR_LIT>'):<EOL><INDENT>kwargs[child] = self[child].slice_cardinal(key)<EOL><DEDENT>elif typ == '<STR_LIT>':<EOL><INDENT>kwargs[child] = self[child].ix[kwargs[parent].index.values]<EOL><DEDENT>elif typ == '<STR_LIT>':<EOL><INDENT>cdf = self[child]<EOL>kwargs[child] = cdf[cdf[parent].isin(kwargs[parent].index.values)]<EOL><DEDENT>elif typ == '<STR_LIT>':<EOL><INDENT>cdf = self[child]<EOL>cin = cdf.index.name<EOL>cols = [col for col in kwargs[parent] if cin == col or (cin == col[:-<NUM_LIT:1>] and col[-<NUM_LIT:1>].isdigit())]<EOL>index = kwargs[parent][cols].stack().astype(np.int64).values<EOL>kwargs[child] = cdf[cdf.index.isin(index)]<EOL><DEDENT><DEDENT>selfs[cardinal_index] = cls(**kwargs)<EOL><DEDENT><DEDENT>return selfs<EOL>
Create an instance of this class for every step in the cardinal dimension.