def slice_cardinal(self, key):
if self._cardinal:<EOL><INDENT>cls = self.__class__<EOL>key = check_key(self[self._cardinal], key, cardinal=True)<EOL>g = self.network(fig=False)<EOL>kwargs = {self._cardinal: self[self._cardinal].ix[key], '<STR_LIT:name>': self.name,<EOL>'<STR_LIT:description>': self.description, '<STR_LIT>': self.meta}<EOL>for parent, child in nx.bfs_edges(g, self._cardinal):<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>return cls(**kwargs)<EOL><DEDENT>
Slice the container according to its (primary) cardinal axis.

The "cardinal" axis can have any name so long as the name matches a
data object attached to the container. The index name for this object
should also match the value of the cardinal axis.

The algorithm builds a network graph representing the data relationships
(including information about the type of relationship) and then traverses
the edge tree (starting from the cardinal table). Each subsequent child
object in the tree is sliced based on its relationship with its parent.

Note:
    Breadth first traversal is performed.

Warning:
    This function does not make a copy (if possible): to ensure a new
    object is created (a copy) use :func:`~exa.core.container.Container.copy`
    after slicing.

    .. code-block:: Python

        myslice = mycontainer[::2].copy()

See Also:
    For data network generation, see :func:`~exa.core.container.Container.network`.
    For information about relationships between data objects see
    :mod:`~exa.core.numerical`.