How to plot pivot chart in python?

Mithil Amin picture Mithil Amin · Apr 20, 2017 · Viewed 9k times · Source

Currenly, I am new in python scripting I am using panda, pivottablejs for creating a script. I have one csv file and I read that csv file using panda and I got the table like this. enter image description here

Now, I want to generate the pivotchart using pivottablejs so for that I have to pass dataframe object in the pivot_ui();

I want to Plot in Pivot Chart the total number of issue status created for every OriginationPhase.

So I tried something like this.

LabelsReviewedByDate = issues_df.groupby(['Status','OriginationPhase'])

pivot_ui(LabelsReviewedByDate)

I know this is wrong but I am new in python scripting. So help me to find the solution.

Thank you

Answer

Andrew L picture Andrew L · Apr 21, 2017

You can just pass the dataframe right to pivot_ui:

import pandas as pd
from pivottablejs import pivot_ui

a= [ [1,'Requirements','bug'],[2,'Design','bug'],[3,'Testing','bug'],[4,'Requirements','bug'],[5,'Requirements','Inquiry'] ]

df  = pd.DataFrame(a,columns =['Issue#','OriginationPhase','Category'])

pivot_ui(df)

enter image description here