Hi I have a data frame as follows:
              b         c         d         e         f         g
a
-2.447948  0.170758  1.246046 -1.452076  1.248984 -0.010419  0.980928
0.038355  0.106015  0.173747  0.934379  0.485859 -0.192508 -0.899376
-0.584441 -0.384552  0.187411 -1.109639  1.529889 -0.059522  0.319147
1.883600  1.211055  1.434066  0.456128  0.456872 -0.575694 -0.741435
0.351659  1.230753  2.026344  0.303135  2.356994 -0.818239  0.346594
0.665147 -0.449289  0.607148  0.584124  0.007701 -1.663303 -0.127717
-1.539684 -0.356195 -0.986359  1.292305  0.675561  0.279108 -1.561347
1.436973  1.787788  1.444885 -0.359050  1.069496  0.517877 -1.133649
-0.317525 -1.101251 -0.146702  0.890189  1.323071  2.246965  0.706875
1.982059  0.144313 -0.014548 -0.300521 -0.583273  0.424427 -0.329592  
index = a, column = col1, col2, col3, values = 10, 12, 15 etc.
I created a for loop to plot a bar chart for each individual product with x-values = columns, y-values = column value.
The code is as follows:
for i in df:
   fig, ax = plt.subplots()
   ax.set_title(i)
   ax.set_ylabel("string")
   plt.tight_layout()    
   df[i].plot.bar(ax=ax)
This successfully creates a bar chart for each group in index a. The problem is columns are still plotted that have 0 values. Is there anyway these columns can be dropped or masked so that each chart only contains x values that have y vales > 0?
I appreciate your help.
Thank you
Aucun commentaire:
Enregistrer un commentaire