Skip to content

Commit

Permalink
Don't combine astype() with loc()
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Apr 12, 2024
1 parent fbc8511 commit acf3482
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python-package/xgboost/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ def make_categorical(
categories = np.arange(0, n_categories)
for col in df.columns:
if rng.binomial(1, cat_ratio, size=1)[0] == 1:
df.loc[:, col] = df[col].astype("category")
df.loc[:, col] = df[col].cat.set_categories(categories)
df[col] = df[col].astype("category")
df[col] = df[col].cat.set_categories(categories)

if sparsity > 0.0:
for i in range(n_features):
Expand Down

0 comments on commit acf3482

Please sign in to comment.