Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pivot error
#1
df2 = pd.DataFrame({'id_user':[1,2,3,4,4,5,5], 'cust_user':[11,22,33,44,44,55,55],
'information':['phon','phon','phone','phone1','phone','phone1','phone'],
'value': [1, '01.01.00', '01.02.00', 2, '01.03.00', 3, '01.04.00']})
df2
df2.pivot(index=['cust_user','id_user'], columns='information', values='value')


Wrong number of items passed 7, placement implies 2.. any link to solve this is appreciated .
Reply
#2
df3 = (pd.pivot_table(df2,index=['cust_user','id_user'],columns=['information'],values=['value'],
                                   aggfunc={'value':np.sum},fill_value=0,))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Help! Pandas EXCEL PIVOT psb3958 1 950 Nov-13-2022, 10:37 PM
Last Post: deanhystad
  group by create pivot table python dawid294 1 1,299 Jun-22-2022, 06:13 PM
Last Post: Larz60+
  SQL Pivot EAV Quentin 2 2,827 Dec-03-2019, 11:52 PM
Last Post: Quentin
  How to pivot a dat UGuntupalli 0 1,897 Oct-17-2019, 11:13 PM
Last Post: UGuntupalli
  Should it be pivot or unstack for this sample shyamdba 0 2,120 Feb-02-2018, 05:50 PM
Last Post: shyamdba

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020