text: Q:
  
  Pandas two dataframes looking up IP's in CIDR's and mapping inCIDR column
  
  I have 2 dataframes. One(df1) with CIDR and a column that will always be one to enrich the second dataframe. The other dataframe(df2) has a list of ips.  I would like to possibly iterate the IP's through the the CIDR's in df1 and label df2 if it is in one.  I have read through the documentation for the libraries ipaddress and netaddr and have used both libraries in the past but I am having trouble figuring out how to use one in this situation.
  If you get the range for cidr 13.64.0.0/11 you would get 13-64.0.0-13.95.255.255. 13.64.1.100 falls in that range
  Dataframes:
  df1
      CIDR           inCIDR
  0   13.64.0.0/11   1
  1   13.96.0.0/13   1
  2   13.104.0.0/14  1
  3   20.34.0.0/15   1
  4   20.36.0.0/14   1
  5   20.40.0.0/13   1
  6   20.128.0.0/16  1
  7   20.140.0.0/15  1
  8   20.144.0.0/14  1
  9   20.160.0.0/12  1
  10  20.176.0.0/14  1
  11  20.180.0.0/14  1
  12  20.184.0.0/13  1
  13  23.96.0.0/13   1
  14  40.64.0.0/10   1
  15  42.159.0.0/16  1
  
  df2
      ipaddress
  0   18.235.100.252   
  1   13.64.1.100 
  2   40.64.11.22  
  3   184.84.243.59   
  4   184.84.243.119  
  5   20.180.22.12  
  6   3.17.7.58  
  7   34.233.202.21  
  8   42.159.10.10 
  
  Desired output:
  df2
      ipaddress        inCIDR
  0   18.235.100.252   0  
  1   13.64.1.100      1
  2   40.64.11.22      1
  3   184.84.243.59    0
  4   184.84.243.119   0
  5   20.180.22.12     1
  6   3.17.7.58        0
  7   34.233.202.21    0 
  8   42.159.10.10     1
  
  Possibly using map to assign the inCIDR like:
  df2['inCIDR'] = df2['ipaddress'].map(df1.set_index('ipaddress')['inCIDR']).fillna(0).astype(int)
  
  A:
  
  If you need to map values based on first two values in ipaddress
  new_df = df1.copy()
  new_df['CIDR'] = new_df['CIDR'].str.extract('(\d+.\d+).')
  
  df2['inCIDR'] = df2['ipaddress'].str.extract('(\d+.\d+).')[0].map(new_df.set_index('CIDR')['inCIDR']).fillna(0).astype(int)
  
      ipaddress       inCIDR
  0   18.235.100.252  0
  1   13.64.1.100     1
  2   40.64.11.22     1
  3   184.84.243.59   0
  4   184.84.243.119  0
  5   20.180.22.12    1
  6   3.17.7.58       0
  7   34.233.202.21   0
  8   42.159.10.10    1
  
  