class_docstr: The core class of DeepGraph (dg).
  
  This class encapsulates the graph representation as ``pandas.DataFrame``
  objects in its attributes ``v`` and ``e``. It can be initialized with a
  node table ``v``, whose rows represent the nodes of the graph, as well
  as an edge table ``e``, whose rows represent edges between the nodes.
  
  Given a node table ``v``, it provides methods to iteratively compute
  pairwise relations between the nodes using arbitrary, user-defined
  functions. These methods provide arguments to parallelize the
  computation and control memory consumption (see ``create_edges`` and
  ``create_edges_ft``).
  
  Also provides methods to partition nodes, edges or an entire graph by
  the graph's properties and labels, and to create common network
  representations and graph objects of popular Python network packages.
  
  Furthermore, it provides methods to visualize graphs and their
  properties and to benchmark the graph construction parameters.
  
  Optionally, the convenience parameter ``supernode_labels_by`` can be
  passed, creating supernode labels by enumerating all distinct (tuples
  of) values of a (multiple) column(s) of ``v`` . Superedge labels can be
  created analogously, by passing the parameter ``superedge_labels_by``.
  
  Parameters
  ----------
  v : pandas.DataFrame or pandas.HDFStore, optional (default=None)
      The node table, a table representation of the nodes of a graph. The
      index of ``v`` must be unique and represents the node indices. The
      column names of ``v`` represent the types of features of the nodes,
      and each cell represents a feature of a node. Only a reference to
      the input DataFrame is created, not a copy. May also be a
      ``pandas.HDFStore``, but only ``create_edges`` and
      ``create_edges_ft`` may then be used (so far).
  
  e : pandas.DataFrame, optional (default=None)
      The edge table, a table representation of the edges between the
      nodes given by ``v``. Its index has to be a
      ``pandas.core.index.MultiIndex``, whose first level contains the
      indices of the source nodes, and the second level contains the
      indices of the target nodes. Each row of ``e`` represents an edge,
      column names of ``e`` represent the types of relations of the edges,
      and each cell in ``e`` represents a relation of an edge. Only a
      reference to the input DataFrame is created, not a copy.
  
  supernode_labels_by : dict, optional (default=None)
      A dictionary whose keys are strings and their values are (lists of)
      column names of ``v``. Appends a column to ``v`` for each key, whose
      values correspond to supernode labels, enumerating all distinct
      (tuples of) values of the column(s) given by the dict's value.
  
  superedge_labels_by : dict, optional (default=None)
      A dictionary whose keys are strings and their values are (lists of)
      column names of ``e``. Appends a column to ``e`` for each key, whose
      values correspond to superedge labels enumerating all distinct
      (tuples of) values of the column(s) given by the dict's value.
  
  Attributes
  ----------
  v : pandas.DataFrame
      See Parameters.
  
  e : pandas.DataFrame
      See Parameters.
  
  n : int
      Property: Number of nodes.
  
  m : int
      Property: Number of edges.
  
  f : pd.DataFrame
      Property: types of features and number of features of corresponding
      type.
  
  r : pd.DataFrame
      Property: types of relations and number of relations of
      corresponding type.
class_docstr_tok: ["The","core","class","of","DeepGraph","(","dg",")",".","This","class","encapsulates","the","graph","representation","as","``","pandas.DataFrame","``","objects","in","its","attributes","``","v","``","and","``","e","``",".","It","can","be","initialized","with","a","node","table","``","v","``",",","whose","rows","represent","the","nodes","of","the","graph",",","as","well","as","an","edge","table","``","e","``",",","whose","rows","represent","edges","between","the","nodes",".","Given","a","node","table","``","v","``",",","it","provides","methods","to","iteratively","compute","pairwise","relations","between","the","nodes","using","arbitrary",",","user-defined","functions",".","These","methods","provide","arguments","to","parallelize","the","computation","and","control","memory","consumption","(","see","``","create_edges","``","and","``","create_edges_ft","``",")",".","Also","provides","methods","to","partition","nodes",",","edges","or","an","entire","graph","by","the","graph","'s","properties","and","labels",",","and","to","create","common","network","representations","and","graph","objects","of","popular","Python","network","packages",".","Furthermore",",","it","provides","methods","to","visualize","graphs","and","their","properties","and","to","benchmark","the","graph","construction","parameters",".","Optionally",",","the","convenience","parameter","``","supernode_labels_by","``","can","be","passed",",","creating","supernode","labels","by","enumerating","all","distinct","(","tuples","of",")","values","of","a","(","multiple",")","column","(","s",")","of","``","v","``",".","Superedge","labels","can","be","created","analogously",",","by","passing","the","parameter","``","superedge_labels_by","``",".","Parameters","--","--","--","--","--","v",":","pandas.DataFrame","or","pandas.HDFStore",",","optional","(","default=None",")","The","node","table",",","a","table","representation","of","the","nodes","of","a","graph",".","The","index","of","``","v","``","must","be","unique","and","represents","the","node","indices",".","The","column","names","of","``","v","``","represent","the","types","of","features","of","the","nodes",",","and","each","cell","represents","a","feature","of","a","node",".","Only","a","reference","to","the","input","DataFrame","is","created",",","not","a","copy",".","May","also","be","a","``","pandas.HDFStore","``",",","but","only","``","create_edges","``","and","``","create_edges_ft","``","may","then","be","used","(","so","far",")",".","e",":","pandas.DataFrame",",","optional","(","default=None",")","The","edge","table",",","a","table","representation","of","the","edges","between","the","nodes","given","by","``","v","``",".","Its","index","has","to","be","a","``","pandas.core.index.MultiIndex","``",",","whose","first","level","contains","the","indices","of","the","source","nodes",",","and","the","second","level","contains","the","indices","of","the","target","nodes",".","Each","row","of","``","e","``","represents","an","edge",",","column","names","of","``","e","``","represent","the","types","of","relations","of","the","edges",",","and","each","cell","in","``","e","``","represents","a","relation","of","an","edge",".","Only","a","reference","to","the","input","DataFrame","is","created",",","not","a","copy",".","supernode_labels_by",":","dict",",","optional","(","default=None",")","A","dictionary","whose","keys","are","strings","and","their","values","are","(","lists","of",")","column","names","of","``","v","``",".","Appends","a","column","to","``","v","``","for","each","key",",","whose","values","correspond","to","supernode","labels",",","enumerating","all","distinct","(","tuples","of",")","values","of","the","column","(","s",")","given","by","the","dict","'s","value",".","superedge_labels_by",":","dict",",","optional","(","default=None",")","A","dictionary","whose","keys","are","strings","and","their","values","are","(","lists","of",")","column","names","of","``","e","``",".","Appends","a","column","to","``","e","``","for","each","key",",","whose","values","correspond","to","superedge","labels","enumerating","all","distinct","(","tuples","of",")","values","of","the","column","(","s",")","given","by","the","dict","'s","value",".","Attributes","--","--","--","--","--","v",":","pandas.DataFrame","See","Parameters",".","e",":","pandas.DataFrame","See","Parameters",".","n",":","int","Property",":","Number","of","nodes",".","m",":","int","Property",":","Number","of","edges",".","f",":","pd.DataFrame","Property",":","types","of","features","and","number","of","features","of","corresponding","type",".","r",":","pd.DataFrame","Property",":","types","of","relations","and","number","of","relations","of","corresponding","type","."]
docstr: Return a superedge DataFrame ``se``.
  
  This method allows you to partition the edges in ``e`` by their types
  of relations, but also by the types of features of their incident
  source and target nodes, and any combination of the three.
  
  Essentially, this method is a wrapper around the pandas groupby method:
  ``se`` = ``e``.groupby(``relations`` + features_s +
  features_t).agg(``relation_funcs``), where ``relations`` are column
  names of ``e``, and in order to group ``e`` by features_s and/or
  features_t, the features of type ``source_features`` and/or
  ``target_features`` (column names of ``v``) are transferred to ``e``,
  appending '_s' and/or '_t' to the corresponding column names of ``e``
  (if they are not already present). The only requirement on the
  combination of ``relations``, ``source_features`` and
  ``target_features`` is that at least on of the lists has to be of
  length >= 1.
  
  By passing a dictionary of functions on the relations of ``e``,
  ``relation_funcs``, one may aggregate user-defined values of the
  partition's elements, the superedges' relations. If ``n_edges`` is
  True, create a column with the number of each superedge's constituent
  edges. If ``return_ge`` is True, return the created groupby object to
  facilitate additional operations, such as ``ge``.apply(func, *args,
  **kwargs).
  
  For details, type help(``g.e``.groupby), and/or inspect the available
  methods of ``ge``.
  
  For examples, see below. For an in-depth description and mathematical
  details of graph partitioning, see
  https://arxiv.org/pdf/1604.00971v1.pdf, in particular Sec. III B, E
  and F.
  
  Parameters
  ----------
  relations : str, int or array_like, optional (default=None)
      Column name(s) of ``e``, indicating the type(s) of relation(s) used
      to induce a (intersection) partition of ``e`` (in conjunction with
      ``source_features`` and ``target_features``).
  
  source_features : str, int or array_like, optional (default=None)
      Column name(s) of ``v``, indicating the type(s) of feature(s) of
      the edges' incident source nodes used to induce a (intersection)
      partition of ``e`` (in conjunction with ``relations`` and
      ``target_features``).
  
  target_features : str, int or array_like, optional (default=None)
      Column name(s) of ``v``, indicating the type(s) of feature(s) of
      the edges' incident target nodes used to induce a (intersection)
      partition of ``e`` (in conjunction with ``relations`` and
      ``source_features``).
  
  relation_funcs : dict, optional (default=None)
      Each key must be a column name of ``e``, each value a (list of)
      function(s), working when passed a ``pandas.DataFrame`` or when
      passed to ``pandas.DataFrame.apply``. See the docstring of
      ``ge``.agg for details: help(``ge``.agg).
  
  n_edges : bool, optional (default=True)
      Whether to create a ``n_edges`` column in ``se``, indicating the
      number of edges in each superedge.
  
  return_ge : bool, optional (default=False)
      If True, also return the pandas groupby object, ``ge``.
  
  Returns
  -------
  se : pd.DataFrame
      The aggreated DataFrame of superedges, ``se``.
  
  ge : pandas.core.groupby.DataFrameGroupBy
      The pandas groupby object, ``ge``.
  
  See also
  --------
  partition_nodes
  partition_graph
  
  Notes
  -----
  Currently, NA groups in GroupBy are automatically excluded (silently).
  One workaround is to use a placeholder (e.g., -1, 'none') for NA values
  before doing the groupby (calling this method). See
  http://stackoverflow.com/questions/18429491/groupby-columns-with-nan-missing-values
  and https://github.com/pydata/pandas/issues/3729.
  
  Examples
  --------
  First, we need to create a graph in order to demonstrate how to
  partition its edge set.
  
  Create a node table:
  
  >>> import pandas as pd
  >>> import deepgraph as dg
  >>> v = pd.DataFrame({'x': [-3.4,2.1,-1.1,0.9,2.3],
  ...                   'time': [0,1,2,5,9],
  ...                   'color': ['g','g','b','g','r'],
  ...                   'size': [1,3,2,3,1]})
  >>> g = dg.DeepGraph(v)
  
  >>> g.v
    color  size  time    x
  0     g     1     0 -3.4
  1     g     3     1  2.1
  2     b     2     2 -1.1
  3     g     3     5  0.9
  4     r     1     9  2.3
  
  Create an edge table:
  
  >>> def some_relations(ft_r, x_s,x_t,color_s,color_t,size_s,size_t):
  ...     dx = x_t - x_s
  ...     v = dx / ft_r
  ...     same_color = color_s == color_t
  ...     larger_than = size_s > size_t
  ...     return dx, v, same_color, larger_than
  >>> g.create_edges_ft(('time', 5), connectors=some_relations)
  >>> g.e.rename(columns={'ft_r': 'dt'}, inplace=True)
  >>> g.e['inds'] = g.e.index.values  # to ease the eyes
  
  >>> g.e
        dx  dt larger_than same_color         v    inds
  s t
  0 1  5.5   1       False       True  5.500000  (0, 1)
    2  2.3   2       False      False  1.150000  (0, 2)
    3  4.3   5       False       True  0.860000  (0, 3)
  1 2 -3.2   1        True      False -3.200000  (1, 2)
    3 -1.2   4       False       True -0.300000  (1, 3)
  2 3  2.0   3       False      False  0.666667  (2, 3)
  3 4  1.4   4        True      False  0.350000  (3, 4)
  
  Partitioning by the type of relation 'larger_than':
  
  >>> g.partition_edges(relations='larger_than',
  ...                   relation_funcs={'dx': ['mean', 'std'],
  ...                                   'same_color': 'sum'})
               n_edges  same_color_sum  dx_mean    dx_std
  larger_than
  False              5               3     2.58  2.558711
  True               2               0    -0.90  3.252691
  
  A refinement of the last partition by the type of relation
  'same_color':
  
  >>> g.partition_edges(relations=['larger_than', 'same_color'],
  ...                   relation_funcs={'dx': ['mean', 'std'],
  ...                                   'dt': lambda x: tuple(x)})
                          n_edges dt_<lambda>   dx_mean    dx_std
  larger_than same_color
  False       False             2      (2, 3)  2.150000  0.212132
              True              3   (1, 5, 4)  2.866667  3.572581
  True        False             2      (1, 4) -0.900000  3.252691
  
  Partitioning by the type of source feature 'color':
  
  >>> g.partition_edges(source_features='color',
  ...                   relation_funcs={'same_color': 'sum'})
           n_edges  same_color
  color_s
  b              1           0
  g              6           3
  
  As one can see, the type of feature 'color' of the source nodes has
  been transferred to ``e``:
  
  >>> g.e
        dx  dt larger_than same_color         v    inds color_s
  s t
  0 1  5.5   1       False       True  5.500000  (0, 1)       g
    2  2.3   2       False      False  1.150000  (0, 2)       g
    3  4.3   5       False       True  0.860000  (0, 3)       g
  1 2 -3.2   1        True      False -3.200000  (1, 2)       g
    3 -1.2   4       False       True -0.300000  (1, 3)       g
  2 3  2.0   3       False      False  0.666667  (2, 3)       b
  3 4  1.4   4        True      False  0.350000  (3, 4)       g
  
  A further refinement of the last partition by the type of source
  feature 'size':
  
  >>> g.partition_edges(source_features=['color', 'size'],
  ...                   relation_funcs={'same_color': 'sum',
  ...                                   'inds': lambda x: tuple(x)})
                  n_edges  same_color                      inds
  color_s size_s
  b       2             1           0                 ((2, 3),)
  g       1             3           2  ((0, 1), (0, 2), (0, 3))
          3             3           1  ((1, 2), (1, 3), (3, 4))
  
  Partitioning by the types of target features ('color', 'size'):
  
  >>> g.partition_edges(target_features=['color', 'size'],
  ...                   relation_funcs={'same_color': 'sum',
  ...                                   'inds': lambda x: tuple(x)})
                  n_edges  same_color                              inds
  color_t size_t
  b       2             2           0                  ((0, 2), (1, 2))
  g       3             4           3  ((0, 1), (0, 3), (1, 3), (2, 3))
  r       1             1           0                         ((3, 4),)
  
  Partitioning by the type of source feature 'color' and the type of
  target feature 'size':
  
  >>> g.partition_edges(source_features='color', target_features='size',
  ...                   relation_funcs={'same_color': 'sum',
  ...                                   'inds': lambda x: tuple(x)})
                  n_edges  same_color                      inds
  color_s size_t
  b       3             1           0                 ((2, 3),)
  g       1             1           0                 ((3, 4),)
          2             2           0          ((0, 2), (1, 2))
          3             3           3  ((0, 1), (0, 3), (1, 3))
  
  A further refinement of the last partition by the type of relation
  'larger_than':
  
  >>> g.partition_edges(relations='larger_than',
  ...                   source_features='color', target_features='size',
  ...                   relation_funcs={'inds': lambda x: tuple(x)})
                              n_edges                      inds
  larger_than color_s size_t
  False       b       3             1                 ((2, 3),)
              g       2             1                 ((0, 2),)
                      3             3  ((0, 1), (0, 3), (1, 3))
  True        g       1             1                 ((3, 4),)
                      2             1                 ((1, 2),)
docstr_tok: ["Return","a","superedge","DataFrame","``","se","``",".","This","method","allows","you","to","partition","the","edges","in","``","e","``","by","their","types","of","relations",",","but","also","by","the","types","of","features","of","their","incident","source","and","target","nodes",",","and","any","combination","of","the","three",".","Essentially",",","this","method","is","a","wrapper","around","the","pandas","groupby","method",":","``","se","``","=","``","e","``",".groupby","(","``","relations","``","+","features_s","+","features_t",")",".agg","(","``","relation_funcs","``",")",",","where","``","relations","``","are","column","names","of","``","e","``",",","and","in","order","to","group","``","e","``","by","features_s","and\/or","features_t",",","the","features","of","type","``","source_features","``","and\/or","``","target_features","``","(","column","names","of","``","v","``",")","are","transferred","to","``","e","``",",","appending","'_s","'","and\/or","'_t","'","to","the","corresponding","column","names","of","``","e","``","(","if","they","are","not","already","present",")",".","The","only","requirement","on","the","combination","of","``","relations","``",",","``","source_features","``","and","``","target_features","``","is","that","at","least","on","of","the","lists","has","to","be","of","length",">","=","1",".","By","passing","a","dictionary","of","functions","on","the","relations","of","``","e","``",",","``","relation_funcs","``",",","one","may","aggregate","user-defined","values","of","the","partition","'s","elements",",","the","superedges","'","relations",".","If","``","n_edges","``","is","True",",","create","a","column","with","the","number","of","each","superedge","'s","constituent","edges",".","If","``","return_ge","``","is","True",",","return","the","created","groupby","object","to","facilitate","additional","operations",",","such","as","``","ge","``",".apply","(","func",",","*","args",",","*","*","kwargs",")",".","For","details",",","type","help","(","``","g.e","``",".groupby",")",",","and\/or","inspect","the","available","methods","of","``","ge","``",".","For","examples",",","see","below",".","For","an","in-depth","description","and","mathematical","details","of","graph","partitioning",",","see","https",":","\/\/arxiv.org\/pdf\/1604.00971v1.pdf",",","in","particular","Sec",".","III","B",",","E","and","F.","Parameters","--","--","--","--","--","relations",":","str",",","int","or","array_like",",","optional","(","default=None",")","Column","name","(","s",")","of","``","e","``",",","indicating","the","type","(","s",")","of","relation","(","s",")","used","to","induce","a","(","intersection",")","partition","of","``","e","``","(","in","conjunction","with","``","source_features","``","and","``","target_features","``",")",".","source_features",":","str",",","int","or","array_like",",","optional","(","default=None",")","Column","name","(","s",")","of","``","v","``",",","indicating","the","type","(","s",")","of","feature","(","s",")","of","the","edges","'","incident","source","nodes","used","to","induce","a","(","intersection",")","partition","of","``","e","``","(","in","conjunction","with","``","relations","``","and","``","target_features","``",")",".","target_features",":","str",",","int","or","array_like",",","optional","(","default=None",")","Column","name","(","s",")","of","``","v","``",",","indicating","the","type","(","s",")","of","feature","(","s",")","of","the","edges","'","incident","target","nodes","used","to","induce","a","(","intersection",")","partition","of","``","e","``","(","in","conjunction","with","``","relations","``","and","``","source_features","``",")",".","relation_funcs",":","dict",",","optional","(","default=None",")","Each","key","must","be","a","column","name","of","``","e","``",",","each","value","a","(","list","of",")","function","(","s",")",",","working","when","passed","a","``","pandas.DataFrame","``","or","when","passed","to","``","pandas.DataFrame.apply","``",".","See","the","docstring","of","``","ge","``",".agg","for","details",":","help","(","``","ge","``",".agg",")",".","n_edges",":","bool",",","optional","(","default=True",")","Whether","to","create","a","``","n_edges","``","column","in","``","se","``",",","indicating","the","number","of","edges","in","each","superedge",".","return_ge",":","bool",",","optional","(","default=False",")","If","True",",","also","return","the","pandas","groupby","object",",","``","ge","``",".","Returns","--","--","--","-","se",":","pd.DataFrame","The","aggreated","DataFrame","of","superedges",",","``","se","``",".","ge",":","pandas.core.groupby.DataFrameGroupBy","The","pandas","groupby","object",",","``","ge","``",".","See","also","--","--","--","--","partition_nodes","partition_graph","Notes","--","--","-","Currently",",","NA","groups","in","GroupBy","are","automatically","excluded","(","silently",")",".","One","workaround","is","to","use","a","placeholder","(","e.g.",",","-1",",","'none","'",")","for","NA","values","before","doing","the","groupby","(","calling","this","method",")",".","See","http",":","\/\/stackoverflow.com\/questions\/18429491\/groupby-columns-with-nan-missing-values","and","https",":","\/\/github.com\/pydata\/pandas\/issues\/3729",".","Examples","--","--","--","--","First",",","we","need","to","create","a","graph","in","order","to","demonstrate","how","to","partition","its","edge","set",".","Create","a","node","table",":",">",">",">","import","pandas","as","pd",">",">",">","import","deepgraph","as","dg",">",">",">","v","=","pd.DataFrame","(","{","'","x","'",":","[","-3.4,2.1",",","-1.1,0.9,2.3","]",",","...","'time","'",":","[","0,1,2,5,9","]",",","...","'color","'",":","[","'","g","'",",","'","g","'",",","'","b","'",",","'","g","'",",","'","r","'","]",",","...","'size","'",":","[","1,3,2,3,1","]","}",")",">",">",">","g","=","dg.DeepGraph","(","v",")",">",">",">","g.v","color","size","time","x","0","g","1","0","-3.4","1","g","3","1","2.1","2","b","2","2","-1.1","3","g","3","5","0.9","4","r","1","9","2.3","Create","an","edge","table",":",">",">",">","def","some_relations","(","ft_r",",","x_s",",","x_t",",","color_s",",","color_t",",","size_s",",","size_t",")",":","...","dx","=","x_t","-","x_s","...","v","=","dx","\/","ft_r","...","same_color","=","color_s","==","color_t","...","larger_than","=","size_s",">","size_t","...","return","dx",",","v",",","same_color",",","larger_than",">",">",">","g.create_edges_ft","(","(","'time","'",",","5",")",",","connectors=some_relations",")",">",">",">","g.e.rename","(","columns=","{","'ft_r","'",":","'dt","'","}",",","inplace=True",")",">",">",">","g.e","[","'inds","'","]","=","g.e.index.values","#","to","ease","the","eyes",">",">",">","g.e","dx","dt","larger_than","same_color","v","inds","s","t","0","1","5.5","1","False","True","5.500000","(","0",",","1",")","2","2.3","2","False","False","1.150000","(","0",",","2",")","3","4.3","5","False","True","0.860000","(","0",",","3",")","1","2","-3.2","1","True","False","-3.200000","(","1",",","2",")","3","-1.2","4","False","True","-0.300000","(","1",",","3",")","2","3","2.0","3","False","False","0.666667","(","2",",","3",")","3","4","1.4","4","True","False","0.350000","(","3",",","4",")","Partitioning","by","the","type","of","relation","'larger_than","'",":",">",">",">","g.partition_edges","(","relations='larger_than","'",",","...","relation_funcs=","{","'dx","'",":","[","'mean","'",",","'std","'","]",",","...","'same_color","'",":","'sum","'","}",")","n_edges","same_color_sum","dx_mean","dx_std","larger_than","False","5","3","2.58","2.558711","True","2","0","-0.90","3.252691","A","refinement","of","the","last","partition","by","the","type","of","relation","'same_color","'",":",">",">",">","g.partition_edges","(","relations=","[","'larger_than","'",",","'same_color","'","]",",","...","relation_funcs=","{","'dx","'",":","[","'mean","'",",","'std","'","]",",","...","'dt","'",":","lambda","x",":","tuple","(","x",")","}",")","n_edges","dt_","<","lambda",">","dx_mean","dx_std","larger_than","same_color","False","False","2","(","2",",","3",")","2.150000","0.212132","True","3","(","1",",","5",",","4",")","2.866667","3.572581","True","False","2","(","1",",","4",")","-0.900000","3.252691","Partitioning","by","the","type","of","source","feature","'color","'",":",">",">",">","g.partition_edges","(","source_features='color","'",",","...","relation_funcs=","{","'same_color","'",":","'sum","'","}",")","n_edges","same_color","color_s","b","1","0","g","6","3","As","one","can","see",",","the","type","of","feature","'color","'","of","the","source","nodes","has","been","transferred","to","``","e","``",":",">",">",">","g.e","dx","dt","larger_than","same_color","v","inds","color_s","s","t","0","1","5.5","1","False","True","5.500000","(","0",",","1",")","g","2","2.3","2","False","False","1.150000","(","0",",","2",")","g","3","4.3","5","False","True","0.860000","(","0",",","3",")","g","1","2","-3.2","1","True","False","-3.200000","(","1",",","2",")","g","3","-1.2","4","False","True","-0.300000","(","1",",","3",")","g","2","3","2.0","3","False","False","0.666667","(","2",",","3",")","b","3","4","1.4","4","True","False","0.350000","(","3",",","4",")","g","A","further","refinement","of","the","last","partition","by","the","type","of","source","feature","'size","'",":",">",">",">","g.partition_edges","(","source_features=","[","'color","'",",","'size","'","]",",","...","relation_funcs=","{","'same_color","'",":","'sum","'",",","...","'inds","'",":","lambda","x",":","tuple","(","x",")","}",")","n_edges","same_color","inds","color_s","size_s","b","2","1","0","(","(","2",",","3",")",",",")","g","1","3","2","(","(","0",",","1",")",",","(","0",",","2",")",",","(","0",",","3",")",")","3","3","1","(","(","1",",","2",")",",","(","1",",","3",")",",","(","3",",","4",")",")","Partitioning","by","the","types","of","target","features","(","'color","'",",","'size","'",")",":",">",">",">","g.partition_edges","(","target_features=","[","'color","'",",","'size","'","]",",","...","relation_funcs=","{","'same_color","'",":","'sum","'",",","...","'inds","'",":","lambda","x",":","tuple","(","x",")","}",")","n_edges","same_color","inds","color_t","size_t","b","2","2","0","(","(","0",",","2",")",",","(","1",",","2",")",")","g","3","4","3","(","(","0",",","1",")",",","(","0",",","3",")",",","(","1",",","3",")",",","(","2",",","3",")",")","r","1","1","0","(","(","3",",","4",")",",",")","Partitioning","by","the","type","of","source","feature","'color","'","and","the","type","of","target","feature","'size","'",":",">",">",">","g.partition_edges","(","source_features='color","'",",","target_features='size","'",",","...","relation_funcs=","{","'same_color","'",":","'sum","'",",","...","'inds","'",":","lambda","x",":","tuple","(","x",")","}",")","n_edges","same_color","inds","color_s","size_t","b","3","1","0","(","(","2",",","3",")",",",")","g","1","1","0","(","(","3",",","4",")",",",")","2","2","0","(","(","0",",","2",")",",","(","1",",","2",")",")","3","3","3","(","(","0",",","1",")",",","(","0",",","3",")",",","(","1",",","3",")",")","A","further","refinement","of","the","last","partition","by","the","type","of","relation","'larger_than","'",":",">",">",">","g.partition_edges","(","relations='larger_than","'",",","...","source_features='color","'",",","target_features='size","'",",","...","relation_funcs=","{","'inds","'",":","lambda","x",":","tuple","(","x",")","}",")","n_edges","inds","larger_than","color_s","size_t","False","b","3","1","(","(","2",",","3",")",",",")","g","2","1","(","(","0",",","2",")",",",")","3","3","(","(","0",",","1",")",",","(","0",",","3",")",",","(","1",",","3",")",")","True","g","1","1","(","(","3",",","4",")",",",")","2","1","(","(","1",",","2",")",",",")"]
code: def partition_edges(
      self,
      relations=None,
      source_features=None,
      target_features=None,
      relation_funcs=None,
      n_edges=True,
      return_ge=False,
  ):
      """Return a superedge DataFrame ``se``.
  
      This method allows you to partition the edges in ``e`` by their types
      of relations, but also by the types of features of their incident
      source and target nodes, and any combination of the three.
  
      Essentially, this method is a wrapper around the pandas groupby method:
      ``se`` = ``e``.groupby(``relations`` + features_s +
      features_t).agg(``relation_funcs``), where ``relations`` are column
      names of ``e``, and in order to group ``e`` by features_s and/or
      features_t, the features of type ``source_features`` and/or
      ``target_features`` (column names of ``v``) are transferred to ``e``,
      appending '_s' and/or '_t' to the corresponding column names of ``e``
      (if they are not already present). The only requirement on the
      combination of ``relations``, ``source_features`` and
      ``target_features`` is that at least on of the lists has to be of
      length >= 1.
  
      By passing a dictionary of functions on the relations of ``e``,
      ``relation_funcs``, one may aggregate user-defined values of the
      partition's elements, the superedges' relations. If ``n_edges`` is
      True, create a column with the number of each superedge's constituent
      edges. If ``return_ge`` is True, return the created groupby object to
      facilitate additional operations, such as ``ge``.apply(func, *args,
      **kwargs).
  
      For details, type help(``g.e``.groupby), and/or inspect the available
      methods of ``ge``.
  
      For examples, see below. For an in-depth description and mathematical
      details of graph partitioning, see
      https://arxiv.org/pdf/1604.00971v1.pdf, in particular Sec. III B, E
      and F.
  
      Parameters
      ----------
      relations : str, int or array_like, optional (default=None)
          Column name(s) of ``e``, indicating the type(s) of relation(s) used
          to induce a (intersection) partition of ``e`` (in conjunction with
          ``source_features`` and ``target_features``).
  
      source_features : str, int or array_like, optional (default=None)
          Column name(s) of ``v``, indicating the type(s) of feature(s) of
          the edges' incident source nodes used to induce a (intersection)
          partition of ``e`` (in conjunction with ``relations`` and
          ``target_features``).
  
      target_features : str, int or array_like, optional (default=None)
          Column name(s) of ``v``, indicating the type(s) of feature(s) of
          the edges' incident target nodes used to induce a (intersection)
          partition of ``e`` (in conjunction with ``relations`` and
          ``source_features``).
  
      relation_funcs : dict, optional (default=None)
          Each key must be a column name of ``e``, each value a (list of)
          function(s), working when passed a ``pandas.DataFrame`` or when
          passed to ``pandas.DataFrame.apply``. See the docstring of
          ``ge``.agg for details: help(``ge``.agg).
  
      n_edges : bool, optional (default=True)
          Whether to create a ``n_edges`` column in ``se``, indicating the
          number of edges in each superedge.
  
      return_ge : bool, optional (default=False)
          If True, also return the pandas groupby object, ``ge``.
  
      Returns
      -------
      se : pd.DataFrame
          The aggreated DataFrame of superedges, ``se``.
  
      ge : pandas.core.groupby.DataFrameGroupBy
          The pandas groupby object, ``ge``.
  
      See also
      --------
      partition_nodes
      partition_graph
  
      Notes
      -----
      Currently, NA groups in GroupBy are automatically excluded (silently).
      One workaround is to use a placeholder (e.g., -1, 'none') for NA values
      before doing the groupby (calling this method). See
      http://stackoverflow.com/questions/18429491/groupby-columns-with-nan-missing-values
      and https://github.com/pydata/pandas/issues/3729.
  
      Examples
      --------
      First, we need to create a graph in order to demonstrate how to
      partition its edge set.
  
      Create a node table:
  
      >>> import pandas as pd
      >>> import deepgraph as dg
      >>> v = pd.DataFrame({'x': [-3.4,2.1,-1.1,0.9,2.3],
      ...                   'time': [0,1,2,5,9],
      ...                   'color': ['g','g','b','g','r'],
      ...                   'size': [1,3,2,3,1]})
      >>> g = dg.DeepGraph(v)
  
      >>> g.v
        color  size  time    x
      0     g     1     0 -3.4
      1     g     3     1  2.1
      2     b     2     2 -1.1
      3     g     3     5  0.9
      4     r     1     9  2.3
  
      Create an edge table:
  
      >>> def some_relations(ft_r, x_s,x_t,color_s,color_t,size_s,size_t):
      ...     dx = x_t - x_s
      ...     v = dx / ft_r
      ...     same_color = color_s == color_t
      ...     larger_than = size_s > size_t
      ...     return dx, v, same_color, larger_than
      >>> g.create_edges_ft(('time', 5), connectors=some_relations)
      >>> g.e.rename(columns={'ft_r': 'dt'}, inplace=True)
      >>> g.e['inds'] = g.e.index.values  # to ease the eyes
  
      >>> g.e
            dx  dt larger_than same_color         v    inds
      s t
      0 1  5.5   1       False       True  5.500000  (0, 1)
        2  2.3   2       False      False  1.150000  (0, 2)
        3  4.3   5       False       True  0.860000  (0, 3)
      1 2 -3.2   1        True      False -3.200000  (1, 2)
        3 -1.2   4       False       True -0.300000  (1, 3)
      2 3  2.0   3       False      False  0.666667  (2, 3)
      3 4  1.4   4        True      False  0.350000  (3, 4)
  
      Partitioning by the type of relation 'larger_than':
  
      >>> g.partition_edges(relations='larger_than',
      ...                   relation_funcs={'dx': ['mean', 'std'],
      ...                                   'same_color': 'sum'})
                   n_edges  same_color_sum  dx_mean    dx_std
      larger_than
      False              5               3     2.58  2.558711
      True               2               0    -0.90  3.252691
  
      A refinement of the last partition by the type of relation
      'same_color':
  
      >>> g.partition_edges(relations=['larger_than', 'same_color'],
      ...                   relation_funcs={'dx': ['mean', 'std'],
      ...                                   'dt': lambda x: tuple(x)})
                              n_edges dt_<lambda>   dx_mean    dx_std
      larger_than same_color
      False       False             2      (2, 3)  2.150000  0.212132
                  True              3   (1, 5, 4)  2.866667  3.572581
      True        False             2      (1, 4) -0.900000  3.252691
  
      Partitioning by the type of source feature 'color':
  
      >>> g.partition_edges(source_features='color',
      ...                   relation_funcs={'same_color': 'sum'})
               n_edges  same_color
      color_s
      b              1           0
      g              6           3
  
      As one can see, the type of feature 'color' of the source nodes has
      been transferred to ``e``:
  
      >>> g.e
            dx  dt larger_than same_color         v    inds color_s
      s t
      0 1  5.5   1       False       True  5.500000  (0, 1)       g
        2  2.3   2       False      False  1.150000  (0, 2)       g
        3  4.3   5       False       True  0.860000  (0, 3)       g
      1 2 -3.2   1        True      False -3.200000  (1, 2)       g
        3 -1.2   4       False       True -0.300000  (1, 3)       g
      2 3  2.0   3       False      False  0.666667  (2, 3)       b
      3 4  1.4   4        True      False  0.350000  (3, 4)       g
  
      A further refinement of the last partition by the type of source
      feature 'size':
  
      >>> g.partition_edges(source_features=['color', 'size'],
      ...                   relation_funcs={'same_color': 'sum',
      ...                                   'inds': lambda x: tuple(x)})
                      n_edges  same_color                      inds
      color_s size_s
      b       2             1           0                 ((2, 3),)
      g       1             3           2  ((0, 1), (0, 2), (0, 3))
              3             3           1  ((1, 2), (1, 3), (3, 4))
  
      Partitioning by the types of target features ('color', 'size'):
  
      >>> g.partition_edges(target_features=['color', 'size'],
      ...                   relation_funcs={'same_color': 'sum',
      ...                                   'inds': lambda x: tuple(x)})
                      n_edges  same_color                              inds
      color_t size_t
      b       2             2           0                  ((0, 2), (1, 2))
      g       3             4           3  ((0, 1), (0, 3), (1, 3), (2, 3))
      r       1             1           0                         ((3, 4),)
  
      Partitioning by the type of source feature 'color' and the type of
      target feature 'size':
  
      >>> g.partition_edges(source_features='color', target_features='size',
      ...                   relation_funcs={'same_color': 'sum',
      ...                                   'inds': lambda x: tuple(x)})
                      n_edges  same_color                      inds
      color_s size_t
      b       3             1           0                 ((2, 3),)
      g       1             1           0                 ((3, 4),)
              2             2           0          ((0, 2), (1, 2))
              3             3           3  ((0, 1), (0, 3), (1, 3))
  
      A further refinement of the last partition by the type of relation
      'larger_than':
  
      >>> g.partition_edges(relations='larger_than',
      ...                   source_features='color', target_features='size',
      ...                   relation_funcs={'inds': lambda x: tuple(x)})
                                  n_edges                      inds
      larger_than color_s size_t
      False       b       3             1                 ((2, 3),)
                  g       2             1                 ((0, 2),)
                          3             3  ((0, 1), (0, 3), (1, 3))
      True        g       1             1                 ((3, 4),)
                          2             1                 ((1, 2),)
  
      """
  
      if not relations:
          relations = []
  
      if not _is_array_like(relations):
          relations = [relations]
  
      # transfer feature columns to g.e, for fast groupby
      if source_features:
          if not _is_array_like(source_features):
              source_features = [source_features]
          cols_s = []
          for sf_col in source_features:
              cols_s.append(sf_col + "_s")
              if sf_col + "_s" not in self.e.columns:
                  s = self.e.index.get_level_values(0)
                  self.e.loc[:, sf_col + "_s"] = self.v.loc[
                      s, sf_col
                  ].values
      else:
          cols_s = []
  
      if target_features:
          if not _is_array_like(target_features):
              target_features = [target_features]
          cols_t = []
          for tf_col in target_features:
              cols_t.append(tf_col + "_t")
              if tf_col + "_t" not in self.e.columns:
                  s = self.e.index.get_level_values(1)
                  self.e.loc[:, tf_col + "_t"] = self.v.loc[
                      s, tf_col
                  ].values
      else:
          cols_t = []
  
      cols = relations + cols_s + cols_t
  
      ge = self.e.groupby(cols)
      se = _aggregate_super_table(
          funcs=relation_funcs, size=n_edges, gt=ge
      )
  
      if n_edges:
          se = se.rename(columns={"size": "n_edges"})
  
      if return_ge:
          return se, ge
      else:
          return se
  
imports: import inspect
  import os
  from datetime import datetime
  from itertools import chain
  from deepgraph.iterators_and_indexers import _matrix_iterator, _ft_iterator, _iter_edges, _initiate_create_edges, _aggregate_super_table
  from deepgraph.utils import _is_array_like, _dic_translator, _create_bin_edges, _flatten
  import numpy
  import pandas
label_desc: Use image node_id 7 for calling the DeepGraph obj's underlying member method code with example usage: obj.partition_edges(relations, source_features, target_features, relation_funcs, n_edges, return_ge) and returns: se,  ge, se