code: def conditional_probability(x, given, df: pd.DataFrame):
      """conditional probability function over categorical variables
         p(x | given) = p(x, given)/p(given)
  
      Args:
          x: the column variable of interest given the column 'given'
          given: the variabe to fix constant
          df: dataframe with columns [given, x]
  
      Returns:
          pd.DataFrame: the conditional probability of x given the column 'given'
      """
  
      return df.groupby([given])[x].apply(
          lambda g: g.value_counts() / len(g)
      )
  
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 1 for calling a global function with example usage: conditional_probability(x, given, df) and returns: df