How to check if dataframe is dask

I have code that needs to work on pandas dataframes as well as dask dataframes. Because of this, at various points in the code I need to check the type to determine which methods to use. As far as I can tell, these all seem to do the trick:

isinstance(df, dask.dataframe.DataFrame)
isinstance(df, dask.dataframe.core.DataFrame)
isinstance(df.values, dask.array.Array)

Is one of these preferred? Or is there a better way to perform this check?

Hi @pwerth,

I would stick with the first one, is there a problem with using it?

Thanks for the reply @guillaumeeb. No problem using any of these, I was simply curious if one of them is the “correct” syntax. I’ll stick with the first option.

1 Like