There are tons of Python/pandas/et al. questions on comparing IP addresses/ CIDR, but surprisingly almost no canonicals. Frankly it's one hell of a mess, and needs organization, cleanup.
- some ask about native Python (2.x/3.x), some about pandas DataFrames (1 string or 4 integer columns), a few use the new Python 3.x package
ipaddress
or the older 2.x 'netaddr ip`, some about other libraries - some relate to single addresses, some to ranges
- some use CIDR subnet mask notation
/23
, some involve wildcards'*'/'xxx'
for subnets, some don't - almost all are about IPv4, few about IPv6 or -aware
- almost all use decimal, not hex or octal
- some use string comparison, some regex, some both, some a custom class (some user-defined, some standard-library)
- some ask for programming simplicity, some optimal performance and scalability on large files/datasets
- some use lists/sets, some regexes, some dataframes, some data structures like n-ary trees
- (Also, making things further disorganized is the right tag should be ip-address, not ip, which relates to the actual protocol. Please help retag. And the CIDR examples are tagged cidr if they're tagged at all, but almost never ip-address).
To cover all these use cases, which questions should be canonical? (not necessarily from the following list, there might be missing need for a canonical, or we could reference a non-Python canonical):
- using regex Python: Efficient way to compare ip addresses in a csv file
- using a custom class Compare IP List to another IP List or IP Range
- comparing with a range Checking if IP address lies within a given range
- solutions for pandas and ipaddress Filter Pandas DataFrame by ip address range
- converting string to pandas DataFrame integer columns Error with split() when converting IP address to decimal using DataFrame
- Python regex to match IP-address with /CIDR
- Check if two CIDR addresses intersect?
- Convert and expand CIDR /8,/9 to /10
- a very old 2009 highly-upvoted question with 2.x answers, some obsolete How can I check if an ip is in a network in python 2.x
- Python - ip <-> subnet match? [duplicate]
- Check if user's IP address is in a range of IP's
- Pandas merge dataframes on ip-address by range
- "How can I sort out all the domain range from 192.55.22.0 to 192.56.22.0 through python"/"Enumerate all IP addresses in domain range..."
- ...and there are tons of others under keywords like 'subnet', 'domain', 'CIDR', 'host' and so on...
- ... please enumerate other candidate or missing canonicals
- ... we should also reference some algorithmic or C/Java/etc. canonicals