1
$\begingroup$

I would like to visualize this data set using Python and probably a visualization tool like Matplotlib. The data set contains three columns: a user id with a question, a user id with an answer, and time. I would like to visualize this data set as a linked list style graph. That is a tree-like structure which would show relationships based on the connections between questions and answers. I've tried different sets of keywords in an attempt to find out how to visualize a data set in this way, but to no avail. [I'm new to data science or analysis]. So I would appreciate some help with this.

$\endgroup$

1 Answer 1

2
$\begingroup$

The graph resulting from this kind of dataset is also known as a Network Graph and the kind of analysis you are trying to do is known as Social Network Analysis.

There are many prominent Python libraries for visualization and subsequent analysis of network graphs. The most widely used is NetworkX. It is easy to add nodes and directed edges in a NetworkX graph and visualize them with Matplotlib.

Installing NetworkX is a prerequisite.

pip install networkx

The following code creates a NetworkX DiGraph object, adds edges(and thereby nodes) to it and plots the graph.

import networkx as nx
from matplotlib import pyplot as plt
G = nx.DiGraph()
G.add_edges_from([(1, 3), (2, 3), (2, 4), (4, 1)])
nx.draw(G)    

Hopefully, this should get you started :)

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.