Skip to content

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

Open
@cBournhonesque

Description

@cBournhonesque

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions