docstr: conditional_graph -- p(x|given) = p(x, given) / p(given)
  
  Useful for finding the conditional probability of a node or edge attribute
  
  returned dataframe sums to 1 on each column
  
  :param x: target column
  :param given: the dependent column
  :param kind: 'nodes' or 'edges'
  :param args/kwargs: additional arguments for g.bind(...)
  :return: a graphistry instance with the conditional graph
          edges weighted by the conditional probability.
          edges are between `x` and `given`, keep in mind that 
          g._edges.columns = [given, x, _probs]
          
docstr_tok: ["conditional_graph","--","p","(","x|given",")","=","p","(","x",",","given",")","\/","p","(","given",")","Useful","for","finding","the","conditional","probability","of","a","node","or","edge","attribute","returned","dataframe","sums","to","1","on","each","column",":","param","x",":","target","column",":","param","given",":","the","dependent","column",":","param","kind",":","'nodes","'","or","'edges'",":","param","args\/kwargs",":","additional","arguments","for","g.bind","(","...",")",":","return",":","a","graphistry","instance","with","the","conditional","graph","edges","weighted","by","the","conditional","probability",".","edges","are","between","`","x","`","and","`","given","`",",","keep","in","mind","that","g._edges.columns","=","[","given",",","x",",","_probs","]"]
code: def conditional_graph(self, x, given, kind="nodes", *args, **kwargs):
      """
      conditional_graph -- p(x|given) = p(x, given) / p(given)
  
      Useful for finding the conditional probability of a node or edge attribute
  
      returned dataframe sums to 1 on each column
  
      :param x: target column
      :param given: the dependent column
      :param kind: 'nodes' or 'edges'
      :param args/kwargs: additional arguments for g.bind(...)
      :return: a graphistry instance with the conditional graph
              edges weighted by the conditional probability.
              edges are between `x` and `given`, keep in mind that
              g._edges.columns = [given, x, _probs]
  
      """
  
      res = self.bind()
  
      if kind == "nodes":
          df = res._nodes
      else:
          df = res._edges
  
      condprobs = conditional_probability(x, given, df)
  
      cprob = pd.DataFrame(list(condprobs.index), columns=[given, x])
      cprob["_probs"] = condprobs.values
  
      res = res.edges(cprob, x, given).bind(
          edge_weight="_probs", *args, **kwargs
      )
  
      return res
  
file_path: pygraphistry/graphistry/compute/conditional.py
imports: import logging
  import pandas
  from typing import Any, List, Union, TYPE_CHECKING
  from typing_extensions import Literal
  from graphistry.Engine import Engine
  from graphistry.Plottable import Plottable
label_desc: Use image node_id 2 for calling the ConditionalMixin obj's underlying member method code with example usage: obj.conditional_graph(x, given, kind) and returns: res