Python Forum
pivot table (excel vs python)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pivot table (excel vs python)
#1
Hello, I'm looking to do a pivot table of a csv file on Python, usually I do it on Excel but I'm looking to automate it. I started with this code
school=df.groupby('domain+country').school.nunique()
title=df.groupby('domain+country').title.nunique()
 
tcddomcount=pandas.merge(school, title, on="domain+country")
 
tcddomcount.columns = ['schooldomain+country','titledomain+country',]
 
 
school2=df.groupby('email').school.nunique()
title2=df.groupby('email').title.nunique()
 
tcdmail=pandas.merge(school2, title2, on="email")
tcdmail.columns = ['schoolmail','titlemail',]
In this code I tried to translate from what I usually do in Excel firstly by taking online mails and schools and vacancies in value
second by taking online domain+country and schools and internship in value
except I don't get the same result with my code
input
[Image: 8lky.png]
what I need to have (with Excel)
[Image: 831v.png]
what i get with python
[Image: o9z5.png]

I get the same result with
table = pandas.pivot_table(df,index=['email'],values=['school','title'], aggfunc=pandas.Series.nunique)
Does this mean that excel and python have two different ways of doing their pivot table? because otherwise python result is not correct
Reply
#2
Re
I understood what the problem was
Python considers that "i" != "I"
Is there any way I can make it so that I can do the DCT without regard to upper/lower case?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Resampling and regrouping using pivot table karlito 4 3,303 Apr-25-2020, 04:03 PM
Last Post: karlito
  Python and a pivot table stilwellj 0 2,311 Nov-04-2019, 01:00 AM
Last Post: stilwellj
  Pivot Table hash problem stilwellj 1 2,210 Oct-30-2019, 08:14 AM
Last Post: Larz60+
  Pivot dataframe SriMekala 2 2,316 Jun-22-2019, 03:02 AM
Last Post: SriMekala

Forum Jump:

User Panel Messages

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