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
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
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)
Enter the region name exactly as it is, without quotes or punctuation signs.
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:
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:
This is a more conceptual-type of activity to make sure the ranges are well understood, and set the tone for the following activities...
Let's keep analyzing ranges... How many total IP addresses are contained in this range?
Final counting activity...
Throughout the entire dataset ip_range_df
, how many IP addresses are assigned to the city_name
New York City?
ip_range_df
that belong to Argentina
or Uruguay
.country_name
, region_name
, city_name
ar_uy_df
It should look something like:
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.