diff --git a/python/cudf/cudf/core/reshape.py b/python/cudf/cudf/core/reshape.py index 8c732474b8c..cd1ce36c6c5 100644 --- a/python/cudf/cudf/core/reshape.py +++ b/python/cudf/cudf/core/reshape.py @@ -995,18 +995,17 @@ def unstack(df, level, fill_value=None): return df df = df.copy(deep=False) if not isinstance(df.index, cudf.MultiIndex): - if isinstance(df, cudf.DataFrame): - dtype = df._columns[0].dtype - for col in df._columns: - if not col.dtype == dtype: - raise ValueError( - "Calling unstack() on single index dataframe" - " with different column datatype is not supported." - ) - res = df.T.stack(dropna=False) - # Result's index is a multiindex - res.index.names = tuple(df.columns.names) + df.index.names - return res + dtype = df._columns[0].dtype + for col in df._columns: + if not col.dtype == dtype: + raise ValueError( + "Calling unstack() on single index dataframe" + " with different column datatype is not supported." + ) + res = df.T.stack(dropna=False) + # Result's index is a multiindex + res.index.names = tuple(df.columns.names) + df.index.names + return res else: columns = df.index._poplevels(level) index = df.index