Home > other >  Python pivot_table set columns, two columns can swap places
Python pivot_table set columns, two columns can swap places

Time:09-17


Statement:
MIS_topN=dfpi [I] pivot_table (columns=[u] 'in production', the index=[u 'PFP'], values=[u 'no', u 'number'])

But I want to make production month in the first row, rankings and number in the second row




The desired effect:

CodePudding user response:

MIS_topN=dfpi [I] pivot_table (columns=[u 'no', u 'number'], index=[u 'PFP'], values=[u] 'in production')
Then the other way around

CodePudding user response:

The other way around data is wrong

CodePudding user response:

reference 1st floor weixin_45903952 response:
MIS_topN=dfpi [I] pivot_table (columns=[u 'no', u 'number'], index=[u 'PFP'], values=[u] 'in production')
Then reverse bai
upside down the data is wrong

CodePudding user response:

Online, etc,,,
  • Related