class_docstr: Base class for parameter estimators in pgmpy.
  
  Parameters
  ----------
  model: pgmpy.models.BayesianNetwork or pgmpy.models.MarkovNetwork or pgmpy.models.NoisyOrModel model
      for which parameter estimation is to be done.
  
  data: pandas DataFrame object
      dataframe object with column names identical to the variable names of the model.
      (If some values in the data are missing the data cells should be set to `numpy.NaN`.
      Note that pandas converts each column containing `numpy.NaN`s to dtype `float`.)
  
  state_names: dict (optional)
      A dict indicating, for each variable, the discrete set of states (or values)
      that the variable can take. If unspecified, the observed values in the data set
      are taken to be the only possible states.
docstr: Return counts how often each state of 'variable' occurred in the data.
  If the variable has parents, counting is done conditionally
  for each state configuration of the parents.
  
  Parameters
  ----------
  variable: string
      Name of the variable for which the state count is to be done.
  
  Returns
  -------
  state_counts: pandas.DataFrame
      Table with state counts for 'variable'
  
  Examples
  --------
  >>> import pandas as pd
  >>> from pgmpy.models import BayesianNetwork
  >>> from pgmpy.estimators import ParameterEstimator
  >>> model = BayesianNetwork([('A', 'C'), ('B', 'C')])
  >>> data = pd.DataFrame(data={'A': ['a1', 'a1', 'a2'],
                                'B': ['b1', 'b2', 'b1'],
                                'C': ['c1', 'c1', 'c2']})
  >>> estimator = ParameterEstimator(model, data)
  >>> estimator.state_counts('A')
      A
  a1  2
  a2  1
  >>> estimator.state_counts('C')
  A  a1      a2
  B  b1  b2  b1  b2
  C
  c1  1   1   0   0
  c2  0   0   1   0
docstr_tok: ["Return","counts","how","often","each","state","of","'variable","'","occurred","in","the","data",".","If","the","variable","has","parents",",","counting","is","done","conditionally","for","each","state","configuration","of","the","parents",".","Parameters","--","--","--","--","--","variable",":","string","Name","of","the","variable","for","which","the","state","count","is","to","be","done",".","Returns","--","--","--","-","state_counts",":","pandas.DataFrame","Table","with","state","counts","for","'variable'","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","from","pgmpy.estimators","import","ParameterEstimator",">",">",">","model","=","BayesianNetwork","(","[","(","'","A","'",",","'","C","'",")",",","(","'","B","'",",","'","C","'",")","]",")",">",">",">","data","=","pd.DataFrame","(","data=","{","'","A","'",":","[","'a1","'",",","'a1","'",",","'a2","'","]",",","'","B","'",":","[","'b1","'",",","'b2","'",",","'b1","'","]",",","'","C","'",":","[","'c1","'",",","'c1","'",",","'c2","'","]","}",")",">",">",">","estimator","=","ParameterEstimator","(","model",",","data",")",">",">",">","estimator.state_counts","(","'","A","'",")","A","a1","2","a2","1",">",">",">","estimator.state_counts","(","'","C","'",")","A","a1","a2","B","b1","b2","b1","b2","C","c1","1","1","0","0","c2","0","0","1","0"]
code: def state_counts(self, variable, weighted=False, **kwargs):
      """
      Return counts how often each state of 'variable' occurred in the data.
      If the variable has parents, counting is done conditionally
      for each state configuration of the parents.
  
      Parameters
      ----------
      variable: string
          Name of the variable for which the state count is to be done.
  
      Returns
      -------
      state_counts: pandas.DataFrame
          Table with state counts for 'variable'
  
      Examples
      --------
      >>> import pandas as pd
      >>> from pgmpy.models import BayesianNetwork
      >>> from pgmpy.estimators import ParameterEstimator
      >>> model = BayesianNetwork([('A', 'C'), ('B', 'C')])
      >>> data = pd.DataFrame(data={'A': ['a1', 'a1', 'a2'],
                                    'B': ['b1', 'b2', 'b1'],
                                    'C': ['c1', 'c1', 'c2']})
      >>> estimator = ParameterEstimator(model, data)
      >>> estimator.state_counts('A')
          A
      a1  2
      a2  1
      >>> estimator.state_counts('C')
      A  a1      a2
      B  b1  b2  b1  b2
      C
      c1  1   1   0   0
      c2  0   0   1   0
      """
  
      parents = sorted(self.model.get_parents(variable))
      return super(ParameterEstimator, self).state_counts(
          variable, parents=parents, weighted=weighted, **kwargs
      )
  
file_path: pgmpy/pgmpy/estimators/base.py
imports: from collections import OrderedDict
  import pandas
label_desc: Use image node_id 2 for calling the ParameterEstimator obj's underlying member method code with example usage: obj.state_counts(variable, weighted) and returns: super