diff --git a/tests/python/test_basic_models.py b/tests/python/test_basic_models.py index 82d0096cf..24d501fa0 100644 --- a/tests/python/test_basic_models.py +++ b/tests/python/test_basic_models.py @@ -578,7 +578,7 @@ class TestModels: y = rng.randn(rows) feature_names = ["test_feature_" + str(i) for i in range(cols)] X_pd = pd.DataFrame(X, columns=feature_names) - X_pd.iloc[:, 3] = X_pd.iloc[:, 3].astype(np.int32) + X_pd[f"test_feature_{3}"] = X_pd.iloc[:, 3].astype(np.int32) Xy = xgb.DMatrix(X_pd, y) assert Xy.feature_types[3] == "int" diff --git a/tests/python/test_with_pandas.py b/tests/python/test_with_pandas.py index 84352d151..a9f20cc06 100644 --- a/tests/python/test_with_pandas.py +++ b/tests/python/test_with_pandas.py @@ -75,7 +75,10 @@ class TestPandas: np.testing.assert_array_equal(result, exp) dm = xgb.DMatrix(dummies) assert dm.feature_names == ['B', 'A_X', 'A_Y', 'A_Z'] - assert dm.feature_types == ['int', 'int', 'int', 'int'] + if int(pd.__version__[0]) >= 2: + assert dm.feature_types == ['int', 'i', 'i', 'i'] + else: + assert dm.feature_types == ['int', 'int', 'int', 'int'] assert dm.num_row() == 3 assert dm.num_col() == 4