Skip to content
Advertisement

How to import csv format Adjacency Matrix hashtag network in CSV file?

My hashtag co-occurrence network is stored as an adjacency matrix in CSV format like this.

JavaScript

Then I use this page as a reference Plot NetworkX Graph from Adjacency Matrix in CSV file

I want to import this matrix into networkx and I tried this:

JavaScript

But I only got this:

JavaScript

How can I import my data correctly, I want to use the python pipeline to calculate degree centrality of each nodes in the network.And importing is the first step.

Advertisement

Answer

The numpy.genfromtxt function has an optional argument called comments that by default is set to "#".

JavaScript

In other words numpy thinks your entire file contains comments and empty rows. You will have to either rename your row and column identifiers or you have to set the comments argument to some other value such as "*"

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement