Closed
Description
From docstring, index
and values
can be optional in df.pivot, but columns
is not
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pivot.html
index : string or object, optional
Column to use to make new frame’s index. If None, uses existing index.
columns : string or object
Column to use to make new frame’s columns.
However, the error message is confusing now, should raise columns
is not optional.
Code example:
>>> df = pd.DataFrame({"foo": ['one', 'one', 'two', 'two'],"bar": ['A', 'A', 'B', 'C'],"baz": [1, 2, 3, 4]})
>>> df.pivot(columns=None)
KeyError: 'None of [None] are in the columns'