Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
40602f9e
Commit
40602f9e
authored
Feb 02, 2018
by
Yu-Yang Huang
Committed by
Guolin Ke
Feb 02, 2018
Browse files
Do not map NaN in pandas categorical columns to -1 (#1226)
parent
3645c2fa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+1
-1
No files found.
python-package/lightgbm/basic.py
View file @
40602f9e
...
@@ -251,7 +251,7 @@ def _data_from_pandas(data, feature_name, categorical_feature, pandas_categorica
...
@@ -251,7 +251,7 @@ def _data_from_pandas(data, feature_name, categorical_feature, pandas_categorica
data
[
col
]
=
data
[
col
].
cat
.
set_categories
(
category
)
data
[
col
]
=
data
[
col
].
cat
.
set_categories
(
category
)
if
len
(
cat_cols
):
# cat_cols is pandas Index object
if
len
(
cat_cols
):
# cat_cols is pandas Index object
data
=
data
.
copy
()
# not alter origin DataFrame
data
=
data
.
copy
()
# not alter origin DataFrame
data
[
cat_cols
]
=
data
[
cat_cols
].
apply
(
lambda
x
:
x
.
cat
.
codes
)
data
[
cat_cols
]
=
data
[
cat_cols
].
apply
(
lambda
x
:
x
.
cat
.
codes
)
.
replace
({
-
1
:
np
.
nan
})
if
categorical_feature
is
not
None
:
if
categorical_feature
is
not
None
:
if
feature_name
is
None
:
if
feature_name
is
None
:
feature_name
=
list
(
data
.
columns
)
feature_name
=
list
(
data
.
columns
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment