Get startedGet started for free

Twitter networks

1. Twitter networks

In this chapter, we're going to be working with Twitter networks. Twitter, after all, is a social networking site, and a major part of its functionality is connecting to other people in networked ways. We'll discuss how there are multiple types of networks which are embedded in Twitter data. We'll generate those networks using the `networkx` package and graph those networks. If you want more details on network analysis, you can check out the Network Analysis in Python courses on DataCamp.

2. Dataset: State of the Union

For this and the next chapter, we're going to use a dataset generated from the 2018 State of the Union address, the first State of the Union address given by Donald Trump. Given Trump's contentious presidency and the processes of political polarization in the US, network analysis can give us a way to look into how political groups are divided online.

3. Network analysis: terms

Let's define some basic network terms. A *node* is the actor within a network. Within Twitter, the nodes are users. An *edge* or *tie* specifies the relationship between nodes. We're going to look at multiple types of relationships. In this course, we are only going to be working with *directed* networks, which means that an edge only goes one way -- the relationships are not mutual. For example, you can retweet someone else, but they don't have to retweet you. The *source* node is where the relationship begins, whereas the *target* node is where the relationship ends.

4. Types of Twitter network ties

We're going to be working with three distinct types of networks within Twitter: retweet networks, quote tweet networks, and reply networks. You can imagine how each of these relationships can have a different social meaning. They also have different source and target users. Let's take a second to explain each of these in detail.

5. Retweet networks

The first is the retweet network. The retweet is a directed edge in which the source node retweets the target node. From the point of view of interpretation, retweets often signal agreement, but you may be familiar with the common refrain: retweets do not equal endorsement. Retweets can also can be used for a more neutral type of information dissemination. In this example, @DataCamp -- the source node -- retweets a tweet by @DatIO -- the target node.

6. Quote networks

The second is the quote tweet network. This is a newer Twitter feature which allows a user to add their own commentary to an existing tweet. The quoting user is the source node, while the quoted user is the target node. Interpretation can vary here -- a quote tweet may signal disagreement, agreement, or some kind of warning or added information. In this case, @alexhanna -- the source user -- quotes a tweet by @today_explained -- the target user.

7. Reply networks

The third type of network is the reply tweet network. The source user replies to a tweet by a target user. Interpretation can vary wildly: I may reply to someone who is my friend or someone I have agreed with, or I may reply to a celebrity with whom I really disagree. In this example, the source user -- @timnitgebru -- quotes a tweet authored by the target user, @histoftech.

8. Let's practice!

Let's review the different types of networks you can analyze from Twitter.