Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pandas nullable types. #7760

Merged
merged 2 commits into from
Mar 30, 2022
Merged

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Mar 28, 2022

  • Check for nullable type input.

cuDF uses nullable type by default, no special support is needed.

Close #6851 .

@trivialfis trivialfis merged commit 9150fdb into dmlc:master Mar 30, 2022
@trivialfis trivialfis deleted the nullable-types branch March 30, 2022 00:51
nullable_alias = {"Int16", "Int32", "Int64"}

# dtype: pd.core.arrays.numeric.NumericDtype
def is_nullable_dtype(dtype: Any) -> bool:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function needed?
It does not seem to make any difference when the same types are in _pandas_dtype_mapper.

@@ -293,6 +316,9 @@ def _transform_pandas_df(
.cat.codes.astype(np.float32)
.replace(-1.0, np.NaN)
)
elif is_nullable_dtype(dtype):
# Converts integer <NA> to float NaN
transformed[data.columns[i]] = data[data.columns[i]].astype(np.float32)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to convert Int64 to float32?

is_bool_dtype,
)

nullable_alias = {"Int16", "Int32", "Int64"}
Copy link

@Ark-kun Ark-kun Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean is nullable as well. Either it should be in this set or this set should be renamed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for pandas nullable types in feature matrix
3 participants