title: Matrix of occurrences of ordinate pair in python
body: <p>I'm using this code just as a example to make it simple:</p>
  <pre><code>import pandas as pd
  
  data = {'x': [1, 2, 3, 1, 2, 1], 'y': [1, 2, 3, 1, 2, 2]}  
  
  # create DataFrame  
  df = pd.DataFrame(data)
  
  #count how many times each tuple (x,y) happens and pu the value in n
  occurrence= df.groupby(['x', 'y']).size().sort_values(ascending=False)
  
  occurrence_df=occurrence.to_frame() 
  
  occurrence_df.reset_index(inplace=True) 
  
  occurrence_df.columns = [ 'x','y','n'] #name the columns
  
  </code></pre>
  <p>I trying to make a matrix like this one:
  <a href="https://i.stack.imgur.com/xZGkH.png" rel="nofollow noreferrer">example of more or less how will be</a></p>
  <p>Axis X: each different values of x. Axis Y: each different values of Y, and each cell with the amount of times that tuple happened</p>
  <p>I think it's a heatmap that resembles the most what I want.</p>
  <p>I'm bashing my head against it for a few days by now, I'm really thankful for the help.</p>