0

Hi I am using pandas pivot functionality .

df1=pd.pivot_table(df, index=[week_column,'Rank_Trx'],columns='Target channel',values= [id_column],aggfunc=pd.Series.nunique)

The output I receive is something like this. enter image description here

However the output i am looking for should look like this. enter image description here

So the columns of the data frame I wish to have should be "Period","Rank_Trx","PDE","Samples","Take no action" Basically I want this a NxN data frame without any multilevel index . I am using the latest pandas version 1.0.5

Oshin Patwa
  • 105
  • 1
  • 8

1 Answers1

0

You can reset the index of the dataframe with

df1 = df1.reset_index()
arhr
  • 1,505
  • 8
  • 16
  • 1
    Hi yes but with that I also need to do some more additional steps either ways found the answer and have posted it thanks. – Oshin Patwa Mar 05 '21 at 13:09