I'm using this code just as a example to make it simple:
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
I trying to make a matrix like this one: example of more or less how will be
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
I think it's a heatmap that resembles the most what I want.
I'm bashing my head against it for a few days by now, I'm really thankful for the help.