Python&R: Learning network analysis, networkx ver. 3

Last Updated on May 8, 2022 by shibatau

III is added.

I. What shall we learn?

Let’s learn the basics of network analysis with Python and R.

You can learn how to download movie data from The Movie Database and transform them to the data for creating network graphs from the following post:

How to Download and Explore Movie Data

II. Get your API key

A TMDB user account is required to request an API key. Sign up TMDB and get an API key at TMDB API.

III. How to get data via API

You can get the movie ID for a film on the page of the film and put it in the scripts shown in the the post above. For example, you can get the data for “The Power of the Dog” with the following code:

If you want to get the release date, run the following script:

# fetch the basic data for Dune as JSON
query = "" + "600583" + "?api_key=" + api_key + "&language=en-US"
response =  requests.get(query)
array_b = response.json()
# show the budget

The “query” may look confusing but you will understand what it means clearer when you learn it creates the following URL.

Please access the page with your browser, and you can see the raw data that you will fetched.

Now let’s get a data frame of the titles and budgets of the films nominated for Oscar 2022 using For Loops and the zip function.

You can see the scripts on Google Colaboratory though they are not completed:

IV. Create network graphs

Following the the post linked above, you can get a DataFrame of ‘edges’ for “The Power of the Dog”— each actor gets a connection to every other actor. The following graph is a network graph with some actors highlighted created with NetworkX.


How to Download and Explore Movie Data

An Introduction to Social Network Analysis with NetworkX: Two Factions of a Karate Club

What is Network Analysis?

Applied Graphical Network Analysis using Python

Network Analysis using R

Preparing Network Data in R

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.