code: def test_cv_as_pandas(self):
      dm, _ = tm.load_agaricus(__file__)
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
          "eval_metric": "error",
      }
  
      cv = xgb.cv(params, dm, num_boost_round=10, nfold=10)
      assert isinstance(cv, pd.DataFrame)
      exp = pd.Index(
          [
              "test-error-mean",
              "test-error-std",
              "train-error-mean",
              "train-error-std",
          ]
      )
      assert len(cv.columns.intersection(exp)) == 4
  
      # show progress log (result is the same as above)
      cv = xgb.cv(
          params, dm, num_boost_round=10, nfold=10, verbose_eval=True
      )
      assert isinstance(cv, pd.DataFrame)
      exp = pd.Index(
          [
              "test-error-mean",
              "test-error-std",
              "train-error-mean",
              "train-error-std",
          ]
      )
      assert len(cv.columns.intersection(exp)) == 4
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          verbose_eval=True,
          show_stdv=False,
      )
      assert isinstance(cv, pd.DataFrame)
      exp = pd.Index(
          [
              "test-error-mean",
              "test-error-std",
              "train-error-mean",
              "train-error-std",
          ]
      )
      assert len(cv.columns.intersection(exp)) == 4
  
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
          "eval_metric": "auc",
      }
      cv = xgb.cv(
          params, dm, num_boost_round=10, nfold=10, as_pandas=True
      )
      assert "eval_metric" in params
      assert "auc" in cv.columns[0]
  
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
          "eval_metric": ["auc"],
      }
      cv = xgb.cv(
          params, dm, num_boost_round=10, nfold=10, as_pandas=True
      )
      assert "eval_metric" in params
      assert "auc" in cv.columns[0]
  
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
          "eval_metric": ["auc"],
      }
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          as_pandas=True,
          early_stopping_rounds=1,
      )
      assert "eval_metric" in params
      assert "auc" in cv.columns[0]
      assert cv.shape[0] < 10
  
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
      }
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          as_pandas=True,
          metrics="auc",
      )
      assert "auc" in cv.columns[0]
  
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
      }
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          as_pandas=True,
          metrics=["auc"],
      )
      assert "auc" in cv.columns[0]
  
      params = {
          "max_depth": 2,
          "eta": 1,
          "objective": "binary:logistic",
          "eval_metric": ["auc"],
      }
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          as_pandas=True,
          metrics="error",
      )
      assert "eval_metric" in params
      assert "auc" not in cv.columns[0]
      assert "error" in cv.columns[0]
  
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          as_pandas=True,
          metrics=["error"],
      )
      assert "eval_metric" in params
      assert "auc" not in cv.columns[0]
      assert "error" in cv.columns[0]
  
      params = list(params.items())
      cv = xgb.cv(
          params,
          dm,
          num_boost_round=10,
          nfold=10,
          as_pandas=True,
          metrics=["error"],
      )
      assert isinstance(params, list)
      assert "auc" not in cv.columns[0]
      assert "error" in cv.columns[0]
  
imports: from typing import Type
  import numpy
  import pytest
  import xgboost
  from xgboost import testing
  from xgboost.core import DataSplitMode
  from xgboost.testing.data import pd_arrow_dtypes, pd_dtypes, run_base_margin_info
label_desc: Use image node_id 9 for calling the TestPandas obj's underlying member method code with example usage: obj.test_cv_as_pandas() without return types