title: Accessing multi-index value in pivot table using pandas in python
body: <p>I have a sample transaction dataframe as below:
  <a href="https://i.stack.imgur.com/JV2ZO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JV2ZO.png" alt="enter image description here" /></a></p>
  <p>I wanted to get the sum of quantity sold for each item grouped by year.
  So, I wrote the below line for it:</p>
  <pre><code>table=pd.pivot_table(df,index=[&quot;ITEMNUMBER&quot;],columns=[&quot;YEAR&quot;],values=[&quot;QTY_SOLD&quot;],aggfunc=np.sum)
  </code></pre>
  <p>And my output comes like this:</p>
  <pre><code>         QTY_SOLD                    
  YEAR           2016 2017 2018 2019 2020
  ITEMNUMBER                             
  A               3.0  0.0  0.0  0.0  0.0
  B               0.0  0.0  0.0  0.0  5.0
  C               0.0  0.0  0.0  0.0  0.0
  </code></pre>
  <p>How can I access each year's data by iterating over the itemnumber column?
  I tried reindexing but that gives me the same output.</p>