Support latest pandas Index type. (#7595)

This commit is contained in:
Jiaming Yuan
2022-01-26 18:20:10 +08:00
committed by GitHub
parent 511805c981
commit 24789429fd
3 changed files with 8 additions and 3 deletions

View File

@@ -109,6 +109,12 @@ class TestPandas:
assert dm.num_row() == 2
assert dm.num_col() == 6
# test Index as columns
df = pd.DataFrame([[1, 1.1], [2, 2.2]], columns=pd.Index([1, 2]))
print(df.columns, isinstance(df.columns, pd.Index))
Xy = xgb.DMatrix(df)
np.testing.assert_equal(np.array(Xy.feature_names), np.array(["1", "2"]))
def test_slice(self):
rng = np.random.RandomState(1994)
rows = 100