Home > Enterprise >  How to replace type: pandas.core.frame.DataFrame with type: modin.pandas.dataframe.DataFrame
How to replace type: pandas.core.frame.DataFrame with type: modin.pandas.dataframe.DataFrame

Time:02-21

I try to replace pandas with modin pandas in the code:

if not isinstance(X, pd.DataFrame):
    raise TypeError(
        "X is not a pandas dataframe. The dataset should be a pandas dataframe.")

but the error is:

DataFrame Expected type <class 'pandas.core.frame.DataFrame'>, found <class 'modin.pandas.dataframe.DataFrame'> instead

How should I change code to solve the problem?

CodePudding user response:

As mentioned by devin-petersohn on Github related to this issue you can simply import modin.pandas as such:

import modin.pandas as m_pd

if not isinstance(X, m_pd.DataFrame):
    raise TypeError(
        "X is not a pandas dataframe. The dataset should be a pandas dataframe.")

an alternative could be to call _to_pandas() function, but then you could run into error handling loop.

Source:

https://github.com/modin-project/modin/issues/896

  • Related