File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -311,10 +311,14 @@ def get_n_bytes(typ: Type) -> int:
311
311
return off_len * (np .iinfo (typ ).bits // 8 )
312
312
313
313
if offset .size == get_n_bytes (np .int64 ):
314
+ if not isinstance (cats , pa .LargeStringArray ):
315
+ raise TypeError (
316
+ "Expecting `pyarrow.StringArray` or `pyarrow.LargeStringArray`,"
317
+ f" got: { type (cats )} ."
318
+ )
314
319
# Convert to 32bit integer, arrow recommends against the use of i64. Also,
315
320
# XGBoost cannot handle large number of categories (> 2**31).
316
- assert isinstance (cats , pa .LargeStringArray ), type (cats )
317
- i32cats = pa .Array .from_pandas (cats .to_numpy (zero_copy_only = False ))
321
+ i32cats = cats .cast (pa .string ())
318
322
mask , offset , data = i32cats .buffers ()
319
323
320
324
if offset .size != get_n_bytes (np .int32 ):
You can’t perform that action at this time.
0 commit comments