Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading