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 supernode DataFrame ``sv``.
  
  This is essentially a wrapper around the pandas groupby method: ``sv``
  = ``v``.groupby(``features``).agg(``feature_funcs``). It creates a
  (intersection) partition of the nodes in ``v`` by the type(s) of
  feature(s) ``features``, resulting in a supernode DataFrame ``sv``. By
  passing a dictionary of functions on the features of ``v``,
  ``feature_funcs``, one may aggregate user-defined values of the
  partition's elements, the supernodes' features. If ``n_nodes`` is True,
  create a column with the number of each supernode's constituent nodes.
  If ``return_gv`` is True, return the created groupby object to
  facilitate additional operations, such as ``gv``.apply(func, *args,
  **kwargs).
  
  For details, type help(``v``.groupby), and/or inspect the available
  methods of ``gv``.
  
  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 A, E
  and F.
  
  Parameters
  ----------
  features : str, int or array_like
      Column name(s) of ``v``, indicating the type(s) of feature(s) used
      to induce a (intersection) partition. Creates a pandas groupby
      object, ``gv`` = ``v``.groupby(``features``).
  
  feature_funcs : dict, optional (default=None)
      Each key must be a column name of ``v``, each value either a
      function, or a list of functions, working when passed a
      ``pandas.DataFrame`` or when passed to ``pandas.DataFrame.apply``.
      See the docstring of ``gv``.agg for details: help(``gv``.agg).
  
  n_nodes : bool, optional (default=True)
      Whether to create a ``n_nodes`` column in ``sv``, indicating the
      number of nodes in each supernode.
  
  return_gv : bool, optional (default=False)
      If True, also return the ``v``.groupby(``features``) object,
      ``gv``.
  
  Returns
  -------
  sv : pd.DataFrame
      The aggreated DataFrame of supernodes, ``sv``.
  
  gv : pandas.core.groupby.DataFrameGroupBy
      The pandas groupby object, ``v``.groupby(``features``).
  
  See also
  --------
  partition_edges
  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 a node table, in order to demonstrate its partitioning:
  
  >>> import pandas as pd
  >>> import deepgraph as dg
  >>> v = pd.DataFrame({'x': [-3.4,2.1,-1.1,0.9,2.3],
  ...                   'time': [0,0,2,2,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     0  2.1
  2     b     2     2 -1.1
  3     g     3     2  0.9
  4     r     1     9  2.3
  
  Create a partition by the type of feature 'color':
  
  >>> g.partition_nodes('color')
         n_nodes
  color
  b            1
  g            3
  r            1
  
  Create an intersection partition by the types of features 'color' and
  'size' (which is a further refinement of the last partition):
  
  >>> g.partition_nodes(['color', 'size'])
              n_nodes
  color size
  b     2           1
  g     1           1
        3           2
  r     1           1
  
  Partition by 'color' and collect x values:
  
  >>> g.partition_nodes('color', {'time': lambda x: list(x)})
         n_nodes       time
  color
  b            1        [2]
  g            3  [0, 0, 2]
  r            1        [9]
  
  Partition by 'color' and aggregate with different functions:
  
  >>> g.partition_nodes('color', {'time': [lambda x: list(x), np.max],
  ...                             'x': [np.mean, np.sum, np.std]})
         n_nodes    x_mean  x_sum     x_std time_<lambda>  time_amax
  color
  b            1 -1.100000   -1.1       NaN           [2]          2
  g            3 -0.133333   -0.4  2.891943     [0, 0, 2]          2
  r            1  2.300000    2.3       NaN           [9]          9
docstr_tok: ["Return","a","supernode","DataFrame","``","sv","``",".","This","is","essentially","a","wrapper","around","the","pandas","groupby","method",":","``","sv","``","=","``","v","``",".groupby","(","``","features","``",")",".agg","(","``","feature_funcs","``",")",".","It","creates","a","(","intersection",")","partition","of","the","nodes","in","``","v","``","by","the","type","(","s",")","of","feature","(","s",")","``","features","``",",","resulting","in","a","supernode","DataFrame","``","sv","``",".","By","passing","a","dictionary","of","functions","on","the","features","of","``","v","``",",","``","feature_funcs","``",",","one","may","aggregate","user-defined","values","of","the","partition","'s","elements",",","the","supernodes","'","features",".","If","``","n_nodes","``","is","True",",","create","a","column","with","the","number","of","each","supernode","'s","constituent","nodes",".","If","``","return_gv","``","is","True",",","return","the","created","groupby","object","to","facilitate","additional","operations",",","such","as","``","gv","``",".apply","(","func",",","*","args",",","*","*","kwargs",")",".","For","details",",","type","help","(","``","v","``",".groupby",")",",","and\/or","inspect","the","available","methods","of","``","gv","``",".","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","A",",","E","and","F.","Parameters","--","--","--","--","--","features",":","str",",","int","or","array_like","Column","name","(","s",")","of","``","v","``",",","indicating","the","type","(","s",")","of","feature","(","s",")","used","to","induce","a","(","intersection",")","partition",".","Creates","a","pandas","groupby","object",",","``","gv","``","=","``","v","``",".groupby","(","``","features","``",")",".","feature_funcs",":","dict",",","optional","(","default=None",")","Each","key","must","be","a","column","name","of","``","v","``",",","each","value","either","a","function",",","or","a","list","of","functions",",","working","when","passed","a","``","pandas.DataFrame","``","or","when","passed","to","``","pandas.DataFrame.apply","``",".","See","the","docstring","of","``","gv","``",".agg","for","details",":","help","(","``","gv","``",".agg",")",".","n_nodes",":","bool",",","optional","(","default=True",")","Whether","to","create","a","``","n_nodes","``","column","in","``","sv","``",",","indicating","the","number","of","nodes","in","each","supernode",".","return_gv",":","bool",",","optional","(","default=False",")","If","True",",","also","return","the","``","v","``",".groupby","(","``","features","``",")","object",",","``","gv","``",".","Returns","--","--","--","-","sv",":","pd.DataFrame","The","aggreated","DataFrame","of","supernodes",",","``","sv","``",".","gv",":","pandas.core.groupby.DataFrameGroupBy","The","pandas","groupby","object",",","``","v","``",".groupby","(","``","features","``",")",".","See","also","--","--","--","--","partition_edges","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","a","node","table",",","in","order","to","demonstrate","its","partitioning",":",">",">",">","import","pandas","as","pd",">",">",">","import","deepgraph","as","dg",">",">",">","v","=","pd.DataFrame","(","{","'","x","'",":","[","-3.4,2.1",",","-1.1,0.9,2.3","]",",","...","'time","'",":","[","0,0,2,2,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","0","2.1","2","b","2","2","-1.1","3","g","3","2","0.9","4","r","1","9","2.3","Create","a","partition","by","the","type","of","feature","'color","'",":",">",">",">","g.partition_nodes","(","'color","'",")","n_nodes","color","b","1","g","3","r","1","Create","an","intersection","partition","by","the","types","of","features","'color","'","and","'size","'","(","which","is","a","further","refinement","of","the","last","partition",")",":",">",">",">","g.partition_nodes","(","[","'color","'",",","'size","'","]",")","n_nodes","color","size","b","2","1","g","1","1","3","2","r","1","1","Partition","by","'color","'","and","collect","x","values",":",">",">",">","g.partition_nodes","(","'color","'",",","{","'time","'",":","lambda","x",":","list","(","x",")","}",")","n_nodes","time","color","b","1","[","2","]","g","3","[","0",",","0",",","2","]","r","1","[","9","]","Partition","by","'color","'","and","aggregate","with","different","functions",":",">",">",">","g.partition_nodes","(","'color","'",",","{","'time","'",":","[","lambda","x",":","list","(","x",")",",","np.max","]",",","...","'","x","'",":","[","np.mean",",","np.sum",",","np.std","]","}",")","n_nodes","x_mean","x_sum","x_std","time_","<","lambda",">","time_amax","color","b","1","-1.100000","-1.1","NaN","[","2","]","2","g","3","-0.133333","-0.4","2.891943","[","0",",","0",",","2","]","2","r","1","2.300000","2.3","NaN","[","9","]","9"]
code: def partition_nodes(
      self, features, feature_funcs=None, n_nodes=True, return_gv=False
  ):
      """Return a supernode DataFrame ``sv``.
  
      This is essentially a wrapper around the pandas groupby method: ``sv``
      = ``v``.groupby(``features``).agg(``feature_funcs``). It creates a
      (intersection) partition of the nodes in ``v`` by the type(s) of
      feature(s) ``features``, resulting in a supernode DataFrame ``sv``. By
      passing a dictionary of functions on the features of ``v``,
      ``feature_funcs``, one may aggregate user-defined values of the
      partition's elements, the supernodes' features. If ``n_nodes`` is True,
      create a column with the number of each supernode's constituent nodes.
      If ``return_gv`` is True, return the created groupby object to
      facilitate additional operations, such as ``gv``.apply(func, *args,
      **kwargs).
  
      For details, type help(``v``.groupby), and/or inspect the available
      methods of ``gv``.
  
      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 A, E
      and F.
  
      Parameters
      ----------
      features : str, int or array_like
          Column name(s) of ``v``, indicating the type(s) of feature(s) used
          to induce a (intersection) partition. Creates a pandas groupby
          object, ``gv`` = ``v``.groupby(``features``).
  
      feature_funcs : dict, optional (default=None)
          Each key must be a column name of ``v``, each value either a
          function, or a list of functions, working when passed a
          ``pandas.DataFrame`` or when passed to ``pandas.DataFrame.apply``.
          See the docstring of ``gv``.agg for details: help(``gv``.agg).
  
      n_nodes : bool, optional (default=True)
          Whether to create a ``n_nodes`` column in ``sv``, indicating the
          number of nodes in each supernode.
  
      return_gv : bool, optional (default=False)
          If True, also return the ``v``.groupby(``features``) object,
          ``gv``.
  
      Returns
      -------
      sv : pd.DataFrame
          The aggreated DataFrame of supernodes, ``sv``.
  
      gv : pandas.core.groupby.DataFrameGroupBy
          The pandas groupby object, ``v``.groupby(``features``).
  
      See also
      --------
      partition_edges
      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 a node table, in order to demonstrate its partitioning:
  
      >>> import pandas as pd
      >>> import deepgraph as dg
      >>> v = pd.DataFrame({'x': [-3.4,2.1,-1.1,0.9,2.3],
      ...                   'time': [0,0,2,2,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     0  2.1
      2     b     2     2 -1.1
      3     g     3     2  0.9
      4     r     1     9  2.3
  
      Create a partition by the type of feature 'color':
  
      >>> g.partition_nodes('color')
             n_nodes
      color
      b            1
      g            3
      r            1
  
      Create an intersection partition by the types of features 'color' and
      'size' (which is a further refinement of the last partition):
  
      >>> g.partition_nodes(['color', 'size'])
                  n_nodes
      color size
      b     2           1
      g     1           1
            3           2
      r     1           1
  
      Partition by 'color' and collect x values:
  
      >>> g.partition_nodes('color', {'time': lambda x: list(x)})
             n_nodes       time
      color
      b            1        [2]
      g            3  [0, 0, 2]
      r            1        [9]
  
      Partition by 'color' and aggregate with different functions:
  
      >>> g.partition_nodes('color', {'time': [lambda x: list(x), np.max],
      ...                             'x': [np.mean, np.sum, np.std]})
             n_nodes    x_mean  x_sum     x_std time_<lambda>  time_amax
      color
      b            1 -1.100000   -1.1       NaN           [2]          2
      g            3 -0.133333   -0.4  2.891943     [0, 0, 2]          2
      r            1  2.300000    2.3       NaN           [9]          9
  
      """
  
      # groupby and aggregate
      gv = self.v.groupby(features)
      sv = _aggregate_super_table(
          funcs=feature_funcs, size=n_nodes, gt=gv
      )
      if n_nodes:
          try:
              sv.rename(columns={"size": "n_nodes"}, inplace=True)
          except TypeError:
              sv = sv.rename(columns={"size": "n_nodes"})
      if return_gv:
          return sv, gv
      else:
          return sv
  
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 6 for calling the DeepGraph obj's underlying member method code with example usage: obj.partition_nodes(features, feature_funcs, n_nodes, return_gv) and returns: sv,  gv, sv