I want to plot bar graph from the dataframe below.
df2 = pd.DataFrame({'URL': ['A','A','B','B','C','C'],
'X': [5,0,7,1,0,6],
'Y': [21,0,4,7,9,0],
'Z':[11,0,8,4,0,0]})
I want to plot bar graph in which I have URL counts on y-axis and X , Y, Z on x-axis with three bars for each. One bar will show the total sum of all the numbers in the respective column and another bar will show number of non zero values in column while the third bar will show the count of duplicate values in the URL column like A comes two times so it will count as one, same for B and C and plot the result on x-axis with each bar.I have managed to draw bar graph for the first two cases (code below) but for third bar I'm unable to draw. If anyone can help me in this case. Thank you
df2.melt("URL").\
groupby("variable").\
agg(sums=("value", "sum"),
nz=("value", lambda x: sum(x != 0))).\
plot(kind="bar")
