IP Addresses Range per Country Analysis
IP Addresses Range per Country Analysis Data Science Project
Data Wrangling with Pandas

IP Addresses Range per Country Analysis

This project deals with a large dataset containing IP Address Ranges from around the world. It consist of some Data Wrangling, like understanding how IPv4 are constructed, expanding the ranges, and some data analysis.
Start this project
IP Addresses Range per Country AnalysisIP Addresses Range per Country Analysis
Project Created by

Santiago Basulto

Project Activities

All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.

All our activities include solutions with explanations on how they work and why we chose them.

codevalidated

Write the function `decimal_to_ip`

Write the function decimal_to_ip that receives a single number (in decimal format) and returns the IPv4 address. Example:

>>> decimal_to_ip(3_653_594_367)
217.197.108.255
codevalidated

Write the function `ip_to_decimal

Now let's reverse the logic to write the function ip_to_decimal. Example of usage:

>>> ip_to_decimal("103.219.7.255")
1742407679

(Check the hint if you're having issues implementing this function)

multiplechoice

To which country belongs the IP Address `217.90.76.113`?

input

To which `region_name` belongs the IP Address `1.0.19.245`

Enter the region name exactly as it is, without quotes or punctuation signs.

codevalidated

Delete the columns `country_code`, `latitude` and `longitude`

We won't use those columns, so better we drop them. Drop the columns in place modifying the ip_range_df object.

If you make a mistake, you'll need to re-read the whole dataframe. Your Dataframe needs to look similar to this:

codevalidated

Add the columns `ipv4_from` and `ipv4_to` with IPv4 representation of the range

Create two new columns ipv4_from and ipv4_to that contain the IP Addresses in IPv4 format of ip_from and ip_to respectively. Your Dataframe will look something like:

input

How many IP addresses are contained in the range `209.28.136.0` to `209.28.136.255`?

This is a more conceptual-type of activity to make sure the ranges are well understood, and set the tone for the following activities...

input

How many IP Addresses are contained in the range `193.55.230.0` to `193.55.239.255`

Let's keep analyzing ranges... How many total IP addresses are contained in this range?

input

How many IP addresses are assigned to

Final counting activity...

Throughout the entire dataset ip_range_df, how many IP addresses are assigned to the city_name New York City?

codevalidated

Select all rows from `Argentina` and `Uruguay`

  • Select the subset of rows from ip_range_df that belong to Argentina or Uruguay.
  • Sort it in ascending mode by: country_name, region_name, city_name
  • Store your result in the variable ar_uy_df

It should look something like:

codevalidated

Generate a complete list of IP Addresses for `ar_uy_df`

Now it's time to unfold that dataframe of IP Ranges into real IPv4 addresses. Generate a new dataframe ar_uy_df that contains the ENTIRE list of IP Addresses assigned to Argentina and Uruguay. The IP address should be contained in a column named ip_addr and it should be the index of the dataframe. It should look something like this (note the index and the name of the column):

WARNING: The sorting done in the previous activity is key to get this activity right.

IP Addresses Range per Country AnalysisIP Addresses Range per Country Analysis
Project Created by

Santiago Basulto

This project is part of

Data Wrangling with Pandas

Explore other projects