In [ ]:
import pandas as pd
import numpy as np
In [ ]:
In [ ]:
numbers = ['(342)123-2345', '410-342-3421', '(234 434-2121', '(301)822-3423', '123-234-3423', '(410)555-4443', 'AAAAHHH', '(XXX)XXX-XXXX', '(602)123-4535', '(234)127-4534']
In [ ]:
#Your code here...
In [ ]:
#This function converts a number from Farenheit to Celsius
toCelsius = lambda x: (float(5)/9)*(x-32)
#Creates a series with numbers that represent temperatures in Farenheit
tempsInFarenheit = pd.Series( [92,33,-5,17,122,87 ])
In [ ]:
#Your code here...
In [ ]:
numList = [1,1,1,1,1,2,4,5,7,5,4,5,6,4,3,5,5,5,6,9,0,7,6,7,5,4,4,7]
In [ ]:
#Your code here...
You are given a Series of IP Addresses and the goal is to limit this data to private IP addresses. Python has an ipaddress module which provides the capability to create, manipulate and operate on IPv4 and IPv6 addresses and networks. Complete documentation is available here: https://docs.python.org/3/library/ipaddress.html.
Here are some examples of how you might use this module:
import ipaddress
myIP = ipaddress.ip_address( '192.168.0.1' )
myNetwork = ipaddress.ip_network( '192.168.0.0/28' )
#Check membership in network
if myIP in myNetwork: #This works
print "Yay!"
#Loop through CIDR blocks
for ip in myNetwork:
print( ip )
192.168.0.0
192.168.0.1
…
…
192.168.0.13
192.168.0.14
192.168.0.15
#Testing to see if an IP is private
if myIP.is_private:
print( "This IP is private" )
else:
print( "Routable IP" )
ipaddress module.
In [ ]:
import ipaddress
hosts = [ '192.168.1.2', '10.10.10.2', '172.143.23.34', '34.34.35.34', '172.15.0.1', '172.17.0.1']
In [ ]:
#Your code here...