Open ChristopherRussell opened 8 months ago
thanks for the report
this currently raises on the latest commit to main
In [1]: df = pl.DataFrame({'a': [1,2,3], 'b':[4,5,6], 'c': ['a', None, None], 'd':[7,8,9]})
...: piv = df.pivot(index='a', columns=['c', 'd'], values='d')
---------------------------------------------------------------------------
DuplicateError Traceback (most recent call last)
<ipython-input-1-67b010500cd5> in ?()
1 df = pl.DataFrame({'a': [1,2,3], 'b':[4,5,6], 'c': ['a', None, None], 'd':[7,8,9]})
----> 2 piv = df.pivot(index='a', columns=['c', 'd'], values='d')
~/polars-dev/py-polars/polars/dataframe/frame.py in ?(self, values, index, columns, aggregate_function, maintain_order, sort_columns, separator)
7431 else:
7432 aggregate_expr = aggregate_function._pyexpr
7433
7434 return self._from_pydf(
-> 7435 self._df.pivot_expr(
7436 values,
7437 index,
7438 columns,
DuplicateError: column with name 'null' has more than one occurrences
but I think your expected output looks right
Checks
Reproducible example
Another pivot one :)
Log output
No response
Issue description
Column names should be ['a', '{"a",7}', {'null', 8}, {'null', 9}], and duplicate columns should not be allowed.
Expected behavior
Column names should be ['a', '{"a",7}', {'null', 8}, {'null', 9}]
Installed versions