class_docstr: Propensity score matching based on the nearest neighbor algorithm.
  
  Attributes:
      caliper (float): threshold to be considered as a match.
      replace (bool): whether to match with replacement or not
      ratio (int): ratio of control / treatment to be matched. used only if
          replace=True.
      shuffle (bool): whether to shuffle the treatment group data before
          matching
      random_state (numpy.random.RandomState or int): RandomState or an int
          seed
      n_jobs (int): The number of parallel jobs to run for neighbors search.
          None means 1 unless in a joblib.parallel_backend context. -1 means using all processors
docstr: Find matches from the control group stratified by groupby_col, by
  matching on specified columns (propensity preferred).
  
  Args:
      data (pandas.DataFrame): total sample data
      treatment_col (str): the column name for the treatment
      score_cols (list): list of column names for matching (propensity
          column should be included)
      groupby_col (str): the column name to be used for stratification
  
  Returns:
      (pandas.DataFrame): The subset of data consisting of matched
          treatment and control group data.
docstr_tok: ["Find","matches","from","the","control","group","stratified","by","groupby_col",",","by","matching","on","specified","columns","(","propensity","preferred",")",".","Args",":","data","(","pandas.DataFrame",")",":","total","sample","data","treatment_col","(","str",")",":","the","column","name","for","the","treatment","score_cols","(","list",")",":","list","of","column","names","for","matching","(","propensity","column","should","be","included",")","groupby_col","(","str",")",":","the","column","name","to","be","used","for","stratification","Returns",":","(","pandas.DataFrame",")",":","The","subset","of","data","consisting","of","matched","treatment","and","control","group","data","."]
code: def match_by_group(
      self, data, treatment_col, score_cols, groupby_col
  ):
      """Find matches from the control group stratified by groupby_col, by
      matching on specified columns (propensity preferred).
  
      Args:
          data (pandas.DataFrame): total sample data
          treatment_col (str): the column name for the treatment
          score_cols (list): list of column names for matching (propensity
              column should be included)
          groupby_col (str): the column name to be used for stratification
  
      Returns:
          (pandas.DataFrame): The subset of data consisting of matched
              treatment and control group data.
      """
      matched = data.groupby(groupby_col).apply(
          lambda x: self.match(
              data=x, treatment_col=treatment_col, score_cols=score_cols
          )
      )
      return matched.reset_index(level=0, drop=True)
  
imports: import argparse
  import logging
  import sys
  import numpy
  import pandas
  from sklearn.neighbors import NearestNeighbors
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils import check_random_state
label_desc: Use image node_id 3 for calling the NearestNeighborMatch obj's underlying member method code with example usage: obj.match_by_group(data, treatment_col, score_cols, groupby_col) and returns: matched