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

Error when using custom dataframe types (modin/lux/dask dataframes) #249

Open
cBournhonesque opened this issue Nov 17, 2021 · 0 comments
Open

Comments

@cBournhonesque
Copy link

Some packages convert the dataframe type into other types that have a similar interface (modin/dask).

This causes issues with sklearn-pandas, more specifically this function:
https://github.com/scikit-learn-contrib/sklearn-pandas/blob/master/sklearn_pandas/dataframe_mapper.py#L311

I fixed this issue by replacing

    def get_dtype(self, ex):
        if isinstance(ex, np.ndarray) or sparse.issparse(ex):
            return [ex.dtype] * ex.shape[1]
        elif isinstance(ex, pd.DataFrame):
            return list(ex.dtypes)
        else:
            raise TypeError(type(ex))

with

    def get_dtype(self, ex):
       if isinstance(ex, np.ndarray) or sparse.issparse(ex):
           return [ex.dtype] * ex.shape[1]
       else:
           return list(ex.dtypes)

But there must be a better solution. How could we handle those separate types of dataframes?

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

No branches or pull requests

1 participant