code: def test_pandas(self):
      import pandas as pd
  
      df = pd.DataFrame(
          [[1, 2.0, True], [2, 3.0, False]], columns=["a", "b", "c"]
      )
      dm = xgb.DMatrix(df, label=pd.Series([1, 2]))
      assert dm.feature_names == ["a", "b", "c"]
      assert dm.feature_types == ["int", "q", "i"]
      assert dm.num_row() == 2
      assert dm.num_col() == 3
  
      # overwrite feature_names and feature_types
      dm = xgb.DMatrix(
          df,
          label=pd.Series([1, 2]),
          feature_names=["x", "y", "z"],
          feature_types=["q", "q", "q"],
      )
      assert dm.feature_names == ["x", "y", "z"]
      assert dm.feature_types == ["q", "q", "q"]
      assert dm.num_row() == 2
      assert dm.num_col() == 3
  
      # incorrect dtypes
      df = pd.DataFrame(
          [[1, 2.0, "x"], [2, 3.0, "y"]], columns=["a", "b", "c"]
      )
      self.assertRaises(ValueError, xgb.DMatrix, df)
  
      # numeric columns
      df = pd.DataFrame([[1, 2.0, True], [2, 3.0, False]])
      dm = xgb.DMatrix(df, label=pd.Series([1, 2]))
      assert dm.feature_names == ["0", "1", "2"]
      assert dm.feature_types == ["int", "q", "i"]
      assert dm.num_row() == 2
      assert dm.num_col() == 3
  
      df = pd.DataFrame([[1, 2.0, 1], [2, 3.0, 1]], columns=[4, 5, 6])
      dm = xgb.DMatrix(df, label=pd.Series([1, 2]))
      assert dm.feature_names == ["4", "5", "6"]
      assert dm.feature_types == ["int", "q", "int"]
      assert dm.num_row() == 2
      assert dm.num_col() == 3
  
file_path: turicreate/src/external/xgboost/tests/python/test_basic.py
imports: import numpy
  import xgboost
  import unittest
  import matplotlib
label_desc: Use image node_id 4 for calling the TestBasic obj's underlying member method code with example usage: obj.test_pandas() without return types