0
respostas

unstack() não ta mais funcionando

o código retorna o seguinte erro:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [566], in <cell line: 1>()
----> 1 configuracao.unstack()

File ~\anaconda3\lib\site-packages\pandas\core\frame.py:8419, in DataFrame.unstack(self, level, fill_value)
   8357 """
   8358 Pivot a level of the (necessarily hierarchical) index labels.
   8359 
   (...)
   8415 dtype: float64
   8416 """
   8417 from pandas.core.reshape.reshape import unstack
-> 8419 result = unstack(self, level, fill_value)
   8421 return result.__finalize__(self, method="unstack")

File ~\anaconda3\lib\site-packages\pandas\core\reshape\reshape.py:478, in unstack(obj, level, fill_value)
    476 if isinstance(obj, DataFrame):
    477     if isinstance(obj.index, MultiIndex):
--> 478         return _unstack_frame(obj, level, fill_value=fill_value)
    479     else:
    480         return obj.T.stack(dropna=False)

File ~\anaconda3\lib\site-packages\pandas\core\reshape\reshape.py:505, in _unstack_frame(obj, level, fill_value)
    503     return obj._constructor(mgr)
    504 else:
--> 505     unstacker = _Unstacker(obj.index, level=level, constructor=obj._constructor)
    506     return unstacker.get_result(
    507         obj._values, value_columns=obj.columns, fill_value=fill_value
    508     )

File ~\anaconda3\lib\site-packages\pandas\core\reshape\reshape.py:140, in _Unstacker.__init__(self, index, level, constructor)
    133 if num_cells > np.iinfo(np.int32).max:
    134     warnings.warn(
    135         f"The following operation may generate {num_cells} cells "
    136         f"in the resulting pandas object.",
    137         PerformanceWarning,
    138     )
--> 140 self._make_selectors()

File ~\anaconda3\lib\site-packages\pandas\core\reshape\reshape.py:192, in _Unstacker._make_selectors(self)
    189 mask.put(selector, True)
    191 if mask.sum() < len(self.index):
--> 192     raise ValueError("Index contains duplicate entries, cannot reshape")
    194 self.group_index = comp_index
    195 self.mask = mask

ValueError: Index contains duplicate entries, cannot reshape