How can I convert a two column array to a matrix with counts of occurences?

One way could be to build a graph using NetworkX and obtain the adjacency matrix directly as a dataframe with nx.to_pandas_adjacency. To account for the co-occurrences of the edges in the graph, we can create a nx.MultiGraph, which allows for multiple edges connecting the same pair of nodes: import networkx as nx G = nx.from_edgelist(pair_array, … Read more

Generating Symmetric Matrices in Numpy

You could just do something like: import numpy as np N = 100 b = np.random.random_integers(-2000,2000,size=(N,N)) b_symm = (b + b.T)/2 Where you can choose from whatever distribution you want in the np.random or equivalent scipy module. Update: If you are trying to build graph-like structures, definitely check out the networkx package: http://networkx.lanl.gov which has … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)