title: Given an empty count matrix and a dictionary that maps customers to lists of purchases, how do I fill the matrix with each purchase?
body: <p>I am stuck on a problem where I am supposed to fill an empty count matrix using a dictionary where the keys are customers and the values are lists of item numbers that represent purchased items.</p>
  <p>So my function is called fill_count_matrix() and it takes an empty count matrix (DataFrame) and a dictionary of customer orders. It is supposed to return a matrix where the values are incremented based on the customer purchases. The diagonals (the cells where the row and column values are the same item) are supposed to count the number of customers who bought that item. The off-diagonal cells (where the row and column values are different items) are supposed to count the number of customers who bought both items.</p>
  <p>Here is an example of the parameters:</p>
  <pre><code>#empty count matrix (index and columns are the same list of item numbers):
       971  972  973  974
  971    0    0    0    0
  972    0    0    0    0
  973    0    0    0    0
  974    0    0    0    0 
  
  #Dict of customer purchaces: 
  {1: ['971', '973'], 2: ['971', '972', '974'], 3: ['971', '974']}
  </code></pre>
  <p>Here is the code I have tried so far:</p>
  <pre><code>def fill_count_matrix(c_matrix, p_matrix):
      '''
      '''
      for i, (key, val) in enumerate(p_matrix.items()):
            for row in c_matrix.index:
                  for col in c_matrix.columns:
                      if row in val and col in val:
                          c_matrix.loc[row,col] += 1
      return c_matrix
  </code></pre>
  <p>Here is the output I get from the parameters above:</p>
  <pre><code>     971  972  973  974
  971    3    1    1    2
  972    1    1    0    1
  973    1    0    1    0
  974    2    1    0    2
  </code></pre>
  <p>The error I am getting is coming from an automated test that is testing my code, so I don't know how much help it will be but here it is:</p>
  <pre><code>FAIL: test_fill_count_matrix (__main__.TestFns)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File &quot;hw1_test.py&quot;, line 40, in test_fill_count_matrix
      self.assertIsNone(fill_count_matrix(self.vals_all['empty_count'][i], self.vals_all['purchase'][i]))
  AssertionError:      971  972  973  974
  971    3    1    1    2
  972    1    1    0    1
  973    1    0    1    0
  974    2    1    0    2 is not None
  
  ----------------------------------------------------------------------
  </code></pre>
  <p>This has been stumping me for hours and I'm not sure what is wrong with my function. Any help would be appreciated.</p>