I have a dataframe which is like below.
     ATTR1  ATTR2  ATTR3  UnitType    Value    Date
  0  1       2      3     TotalSales  10       10/2020
  1  1       2      3     Canceled    1        10/2020
  2  1       2      3     Returned    3        10/2020
  3  3       2      1     TotalSales  10       10/2020
  4  3       2      1     Canceled    1        10/2020
  5  3       2      1     Returned    3        10/2020
Data continues with different months. I want to make Date only 1 row for each attr1-2-3 combination and make new columns for each unit type.
I tried pivot function like below but it didn't work.
data.pivot(index=['Date', 'ATTR1', 'ATTR2', 'ATTR3'], columns='UnitType', values='Value')
It gives the following error.
Length of passed values is 1346544, index implies 4
 
    