class_docstr: A wrapper for `Tesseract <https://github.com/tesseract-ocr/tesseract>`_ Text
  Detection APIs based on `PyTesseract <https://github.com/tesseract-ocr/tesseract>`_.
class_docstr_tok: ["A","wrapper","for","`","Tesseract","<","https",":","\/\/github.com\/tesseract-ocr\/tesseract",">","`","_","Text","Detection","APIs","based","on","`","PyTesseract","<","https",":","\/\/github.com\/tesseract-ocr\/tesseract",">","`","_","."]
docstr: Gather the OCR'ed text, bounding boxes, and confidence
  in a given aggeragation level.
docstr_tok: ["Gather","the","OCR'ed","text",",","bounding","boxes",",","and","confidence","in","a","given","aggeragation","level","."]
code: def gather_data(response, agg_level):
      """
      Gather the OCR'ed text, bounding boxes, and confidence
      in a given aggeragation level.
      """
      assert isinstance(
          agg_level, TesseractFeatureType
      ), f"Invalid agg_level {agg_level}"
      res = response["data"]
      df = (
          res[~res.text.isna()]
          .groupby(agg_level.group_levels)
          .apply(
              lambda gp: pd.Series(
                  [
                      gp["left"].min(),
                      gp["top"].min(),
                      gp["width"].max(),
                      gp["height"].max(),
                      gp["conf"].mean(),
                      gp["text"].str.cat(sep=" "),
                  ]
              )
          )
          .reset_index(drop=True)
          .reset_index()
          .rename(
              columns={
                  0: "x_1",
                  1: "y_1",
                  2: "w",
                  3: "h",
                  4: "score",
                  5: "text",
                  "index": "id",
              }
          )
          .assign(
              x_2=lambda x: x.x_1 + x.w,
              y_2=lambda x: x.y_1 + x.h,
              block_type="rectangle",
          )
          .drop(columns=["w", "h"])
      )
  
      return load_dataframe(df)
  
file_path: layout-parser/src/layoutparser/ocr/tesseract_agent.py
imports: import io
  import csv
  import pickle
  import pandas
  from .base import BaseOCRAgent, BaseOCRElementType
  from ..io import load_dataframe
  from ..file_utils import is_pytesseract_available
label_desc: Use image node_id 5 for calling the TesseractAgent obj's underlying member method code with example usage: obj.gather_data(response, agg_level) and returns: load_dataframe