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.

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.


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)

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("")

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


To which country belongs the IP Address ``?


To which `region_name` belongs the IP Address ``

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


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:


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:


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

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


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

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


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?


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:


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

Santiago Basulto

This project is part of

Data Wrangling with Pandas

Explore other projects