1

For this sample code :

       df_pivot_comp = pd.pivot_table(pd.read_excel(excel_file,sheet_name=sheet),\
                       values=['COMPILER WARNING'], columns=None, index=['GROUP','DOMAIN'],\
                       aggfunc='count',margins=True,margins_name='Total',fill_value=0)
       df_pivot_comp["Total"] = df_pivot_comp
       group_count = df_pivot_comp.reset_index().groupby(["GROUP"]).agg({"COMPILER WARNING": sum})
       for idx in df_pivot_comp.index.get_level_values(0).unique():
           df_pivot_comp.loc[(idx,), "Total"] = group_count.loc[idx].values[0]
       for idx_0 in df_pivot_comp.index.get_level_values(0).unique():  # bar, foo, total
           if idx_0 == "Total":
               continue
       for idx_1 in df_pivot_comp.loc[(idx_0,), :].index[1:]:
           df_pivot_comp.loc[(idx_0, idx_1), "Total"] = "" 

This is the ouptut i get : enter image description here

For the three pivot tables present in thr excel , i want to plot three bar graphs below each column in the same page, but im not able to , please help me with this

       df_pivot_comp.groupby('GROUP')['Total'].value_counts().unstack(level=1).plot.bar(stacked=True)
       plt.legend(loc='upper left',prop = {'size':7},bbox_to_anchor=(1,1))
       plt.tight_layout(pad=3)

I tried with this and im getting the bar graphs but that bar graphs are not getting pasted in the excel and the bar graphs are vanishing once i close with Please help me with this as ive tried with all i know

0 Answers0