-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
DataFrame.stack()
and DataFrame.unstack()
methods require docstring update.
DataFrame.stack()
docstring mentions that method converts DataFrame to Series, and returns a Series. This is only the case when columns has only one level. In case columns has multiple levels, method returns a DataFrame.
DataFrame.unstack()
docstring is mainly a copy of the Series.unstack()
docstring, example should operate on a DataFrame and not a Series.
Concerning the behavior, when the DataFrame index is a single level one, unstack() raises:
AttributeError: `Index` object has no attribute `levels`
DataFrame.unstack()
assumes a DataFrame with a multilevel index, it can not operate on single level index, maybe the method could return a Series in case unstack() operates on DataFrame with single level index, similar as stack() does in case of single level columns?