0
aaaa = df3.groupby("BU").apply(lambda sub: sub.pivot_table(
       values=["Cost YTD", 
       "Forecasted Cost in Current FY", 
       "Plan FY",
       "Variance FY"],
       index=["Project ID","Name"], 
       fill_value=0, 
       aggfunc=np.sum, 
       margins=True,
       margins_name='SubTotal').astype(int))

For some reason when I extract my pivot table to excel my value columns are not in order has instructed. How do I fix that?

Thanks,

David Erickson
  • 16,433
  • 2
  • 19
  • 35
  • 1
    Can you kindly provide a minimum reproducible example of the input data just before you run that line of code as well as expected output (no images). Please see: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – David Erickson Oct 14 '20 at 03:26
  • df3 =pd.read_csv(r'\\oak\data\Tor\file\WWWW\WJI\AAAA Master Report.csv') df3 = df3[(df3["Vertical Head"]=="Smith,John")] – user14362477 Oct 14 '20 at 20:56

0 Answers0