Fix tests with pandas 2.0. (#9014)

* Fix tests with pandas 2.0.

- `is_categorical` is replaced by `is_categorical_dtype`.
- one hot encoding returns boolean type instead of integer type.
This commit is contained in:
Jiaming Yuan
2023-04-11 00:17:34 +08:00
committed by GitHub
parent ebd64f6e22
commit 2c8d735cb3
2 changed files with 8 additions and 5 deletions

View File

@@ -664,7 +664,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"