I have some data in pandas dataframe form below, where the columns represent discrete skills and the rows represent discrete jobs. A 1 is present only if the skill is required by the job, otherwise 0.
skill_1, skill_2,
job_1 1, 0,
job_2 0, 0,
job_3 1, 1,
I want to create a graph to visualize this relationship between jobs and skills, using networkx. I've tried two methods, one on the dataframe, itself, nx.from_pandas_adjacency
and nx.from_numpy_matrix
. The latter method was applied to a numpy representation of the dataframe, where the column and row names were removed.
In either situation, an error was raised because this is a non_square matrix. This makes sense as networkx is likely interpreting both columns and rows as the same set of nodes. However, the columns and nodes represent distinctly different things here. Two jobs are connected by the skill(s) they share and two skills are connected by the job(s) they share, but there is no direct edge between any two skills or any two jobs.
How can I import my data into networkx given that my rows and columns are different sets of nodes?