class_docstr: A predictor for XGBoost models.
  
  Args:
      model: The XGBoost booster to use for predictions.
      preprocessor: A preprocessor used to transform data batches prior
          to prediction.
code: def _predict_pandas(
      self,
      data: "pd.DataFrame",
      feature_columns: Optional[Union[List[str], List[int]]] = None,
      dmatrix_kwargs: Optional[Dict[str, Any]] = None,
      **predict_kwargs,
  ) -> "pd.DataFrame":
      dmatrix_kwargs = dmatrix_kwargs or {}
  
      feature_names = None
      if TENSOR_COLUMN_NAME in data:
          data = data[TENSOR_COLUMN_NAME].to_numpy()
          data = _unwrap_ndarray_object_type_if_needed(data)
          if feature_columns:
              # In this case feature_columns is a list of integers
              data = data[:, feature_columns]
      elif feature_columns:
          # feature_columns is a list of integers or strings
          data = data[feature_columns].to_numpy()
          # Only set the feature names if they are strings
          if all(isinstance(fc, str) for fc in feature_columns):
              feature_names = feature_columns
      else:
          feature_columns = data.columns.tolist()
          data = data.to_numpy()
  
          if all(isinstance(fc, str) for fc in feature_columns):
              feature_names = feature_columns
  
      if feature_names:
          dmatrix_kwargs["feature_names"] = feature_names
  
      matrix = xgboost.DMatrix(data, **dmatrix_kwargs)
      df = pd.DataFrame(self.model.predict(matrix, **predict_kwargs))
      df.columns = (
          ["predictions"]
          if len(df.columns) == 1
          else [f"predictions_{i}" for i in range(len(df.columns))]
      )
      return df
  
file_path: ray/python/ray/train/xgboost/xgboost_predictor.py
imports: from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
  import pandas
  import xgboost
  from ray.air.constants import TENSOR_COLUMN_NAME
  from ray.air.data_batch_type import DataBatchType
  from ray.air.util.data_batch_conversion import _unwrap_ndarray_object_type_if_needed
  from ray.train.predictor import Predictor
  from ray.train.xgboost import XGBoostCheckpoint
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 5 for calling the XGBoostPredictor obj's underlying member method code with example usage: obj._predict_pandas(data, feature_columns, dmatrix_kwargs) and returns: df