Skip to content

Commit

Permalink
Deprecation warning from pandas.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Sep 30, 2020
1 parent 96f4aed commit cb2c684
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions python-package/xgboost/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def _is_pandas_df(data):
return False
return isinstance(data, pd.DataFrame)


def _is_modin_df(data):
try:
import modin.pandas as pd
Expand Down Expand Up @@ -188,11 +189,11 @@ def _transform_pandas_df(data, enable_categorical,
feature_names=None, feature_types=None,
meta=None, meta_type=None):
from pandas import MultiIndex, Int64Index
from pandas.api.types import is_sparse, is_categorical
from pandas.api.types import is_sparse, is_categorical_dtype

data_dtypes = data.dtypes
if not all(dtype.name in _pandas_dtype_mapper or is_sparse(dtype) or
(is_categorical(dtype) and enable_categorical)
(is_categorical_dtype(dtype) and enable_categorical)
for dtype in data_dtypes):
bad_fields = [
str(data.columns[i]) for i, dtype in enumerate(data_dtypes)
Expand Down Expand Up @@ -220,7 +221,7 @@ def _transform_pandas_df(data, enable_categorical,
if is_sparse(dtype):
feature_types.append(_pandas_dtype_mapper[
dtype.subtype.name])
elif is_categorical(dtype) and enable_categorical:
elif is_categorical_dtype(dtype) and enable_categorical:
feature_types.append('categorical')
else:
feature_types.append(_pandas_dtype_mapper[dtype.name])
Expand Down
2 changes: 1 addition & 1 deletion src/tree/tree_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ void RegTree::LoadCategoricalSplit(Json const& in) {
if (!categories_nodes.empty()) {
last_cat_node = get<Integer const>(categories_nodes[cnt]);
}
for (size_t nidx = 0; nidx < param.num_nodes; ++nidx) {
for (bst_node_t nidx = 0; nidx < param.num_nodes; ++nidx) {
if (nidx == last_cat_node) {
auto j_begin = get<Integer const>(categories_segments[cnt]);
auto j_end = get<Integer const>(categories_sizes[cnt]) + j_begin;
Expand Down

0 comments on commit cb2c684

Please sign in to comment.