简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM