# High speed conversion of IP addresses represented in CIDR notation into their corresponding start and end IPs, along with their respective subnet masks.
## Tested against Windows 10 / Python 3.10 / Anaconda
## pip install cirdhighspeedcoverter
The cidr_to_ip_and_subnet_mask function serves as a versatile tool for converting
IP addresses represented in CIDR (Classless Inter-Domain Routing) notation into
their corresponding start and end IPs, along with their respective subnet masks.
This process is crucial in network management and data analysis tasks.
By automating this conversion, the function significantly accelerates the handling of
large datasets containing CIDR notation IP addresses. It accepts various input formats,
including lists, pandas Series, and DataFrames, enhancing its adaptability.
Leveraging optimized array operations through NumPy and numexpr,
the function ensures efficient processing, particularly with extensive datasets.
This functionality is valuable to network administrators, data scientists, security
professionals, and developers alike, providing a streamlined approach for tasks
involving IP address manipulation and analysis. Ultimately, it simplifies the management
of network configurations and enhances the efficiency of data processing pipelines
that involve IP address transformations.
## Advantages:
### Automation and Efficiency:
It automates the process of converting CIDR notation IP addresses to start and
end IP addresses along with subnet masks. This can save a significant
amount of time and effort compared to manual conversion.
### Scalability:
It can handle a large number of CIDR notation IP addresses
efficiently, making it suitable for processing datasets
with a large number of IP addresses.
### Flexibility:
The function can accept input in various formats, including lists, pandas Series, and DataFrames.
This makes it versatile and adaptable to different data structures.
### Optimized Computation:
The function leverages NumPy and numexpr for efficient array operations,
which can lead to improved performance, especially with large datasets.
### Readability and Reusability:
The function is well-organized and includes meaningful variable names,
making it easy for others (and the original developer) to understand and reuse the code.
```python
from cirdhighspeedcoverter import cidr_to_ip_and_subnet_mask
df2 = pd.read_csv(
r"C:\Users\hansc\Downloads\GeoLite2-City-CSV_20230908\GeoLite2-City-CSV_20230908\GeoLite2-City-Blocks-IPv4.csv"
)
print(df2[:10].to_string())
df = cidr_to_ip_and_subnet_mask(df2[:1000].network.to_list())
df = cidr_to_ip_and_subnet_mask(df2[:1000].network)
df = cidr_to_ip_and_subnet_mask(df2[:1000], column="network")
print(df[:10].to_string())
network geoname_id registered_country_geoname_id represented_country_geoname_id is_anonymous_proxy is_satellite_provider postal_code latitude longitude accuracy_radius
0 1.0.0.0/24 2077456.0 2077456.0 NaN 0 0 NaN -33.4940 143.2104 1000.0
1 1.0.1.0/24 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0
2 1.0.2.0/23 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0
3 1.0.4.0/22 2147714.0 2077456.0 NaN 0 0 2000 -33.8715 151.2006 1000.0
4 1.0.8.0/21 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0
5 1.0.16.0/20 1861060.0 1861060.0 NaN 0 0 NaN 35.6897 139.6895 500.0
6 1.0.32.0/19 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0
7 1.0.64.0/22 1862415.0 1861060.0 NaN 0 0 730-0851 34.3927 132.4501 5.0
8 1.0.68.0/23 11818936.0 1861060.0 NaN 0 0 739-0424 34.2976 132.2898 20.0
9 1.0.70.0/25 1856520.0 1861060.0 NaN 0 0 730-0011 34.3978 132.4525 10.0
aa_startip aa_subnet aa_startip_int aa_endip aa_endip_int aa_subnetmask
0 1.0.0.0 24 16777216 1.0.0.255 16777471 255.255.255.0
1 1.0.1.0 24 16777472 1.0.1.255 16777727 255.255.255.0
2 1.0.2.0 23 16777728 1.0.3.255 16778239 255.255.254.0
3 1.0.4.0 22 16778240 1.0.7.255 16779263 255.255.252.0
4 1.0.8.0 21 16779264 1.0.15.255 16781311 255.255.248.0
5 1.0.16.0 20 16781312 1.0.31.255 16785407 255.255.240.0
6 1.0.32.0 19 16785408 1.0.63.255 16793599 255.255.224.0
7 1.0.64.0 22 16793600 1.0.67.255 16794623 255.255.252.0
8 1.0.68.0 23 16794624 1.0.69.255 16795135 255.255.254.0
9 1.0.70.0 25 16795136 1.0.70.127 16795263 255.255.255.128
Convert CIDR notation IP addresses to start and end IP addresses along with subnet masks.
This function takes a list or pandas DataFrame/Series containing CIDR notation IP addresses
and returns a DataFrame with the following columns:
- 'aa_startip': The starting IP address in string format.
- "aa_subnet": The subnet mask in integer format (uint8).
- 'aa_endip': The ending IP address in string format.
- 'aa_startip_int': The starting IP address in integer format (uint32).
- 'aa_endip_int': The ending IP address in integer format (uint32).
- 'aa_subnetmask': The subnet mask in string format.
Parameters:
-----------
df_series_list : list, pandas.Series, or pandas.DataFrame
The input data containing CIDR notation IP addresses.
column : str, optional (default="network")
The name of the column containing the CIDR notation IP addresses if df_series_list is a DataFrame.
Returns:
--------
pandas.DataFrame
A DataFrame with the converted IP addresses and subnet masks.
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/cirdhighspeedcoverter",
"name": "cirdhighspeedcoverter",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "CIDR,convert",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/97/72/86c072adf6962b66e976af6a14c55e3ccc58d5240cf242f05d396e7ebbee/cirdhighspeedcoverter-0.10.tar.gz",
"platform": null,
"description": "\r\n# High speed conversion of IP addresses represented in CIDR notation into their corresponding start and end IPs, along with their respective subnet masks.\r\n\r\n## Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n## pip install cirdhighspeedcoverter\r\n\r\n\r\nThe cidr_to_ip_and_subnet_mask function serves as a versatile tool for converting \r\nIP addresses represented in CIDR (Classless Inter-Domain Routing) notation into \r\ntheir corresponding start and end IPs, along with their respective subnet masks. \r\nThis process is crucial in network management and data analysis tasks. \r\nBy automating this conversion, the function significantly accelerates the handling of \r\nlarge datasets containing CIDR notation IP addresses. It accepts various input formats, \r\nincluding lists, pandas Series, and DataFrames, enhancing its adaptability. \r\nLeveraging optimized array operations through NumPy and numexpr, \r\nthe function ensures efficient processing, particularly with extensive datasets. \r\nThis functionality is valuable to network administrators, data scientists, security \r\nprofessionals, and developers alike, providing a streamlined approach for tasks \r\ninvolving IP address manipulation and analysis. Ultimately, it simplifies the management \r\nof network configurations and enhances the efficiency of data processing pipelines \r\nthat involve IP address transformations.\r\n\r\n## Advantages:\r\n\r\n### Automation and Efficiency: \r\nIt automates the process of converting CIDR notation IP addresses to start and \r\nend IP addresses along with subnet masks. This can save a significant \r\namount of time and effort compared to manual conversion.\r\n\r\n### Scalability: \r\nIt can handle a large number of CIDR notation IP addresses \r\nefficiently, making it suitable for processing datasets \r\nwith a large number of IP addresses.\r\n\r\n### Flexibility: \r\nThe function can accept input in various formats, including lists, pandas Series, and DataFrames. \r\nThis makes it versatile and adaptable to different data structures.\r\n\r\n### Optimized Computation: \r\nThe function leverages NumPy and numexpr for efficient array operations, \r\nwhich can lead to improved performance, especially with large datasets.\r\n\r\n### Readability and Reusability: \r\nThe function is well-organized and includes meaningful variable names, \r\nmaking it easy for others (and the original developer) to understand and reuse the code.\r\n\r\n\r\n\r\n```python\r\n\r\nfrom cirdhighspeedcoverter import cidr_to_ip_and_subnet_mask\r\ndf2 = pd.read_csv(\r\n r\"C:\\Users\\hansc\\Downloads\\GeoLite2-City-CSV_20230908\\GeoLite2-City-CSV_20230908\\GeoLite2-City-Blocks-IPv4.csv\"\r\n)\r\nprint(df2[:10].to_string())\r\ndf = cidr_to_ip_and_subnet_mask(df2[:1000].network.to_list())\r\ndf = cidr_to_ip_and_subnet_mask(df2[:1000].network)\r\ndf = cidr_to_ip_and_subnet_mask(df2[:1000], column=\"network\")\r\nprint(df[:10].to_string())\r\n\r\n\r\n network geoname_id registered_country_geoname_id represented_country_geoname_id is_anonymous_proxy is_satellite_provider postal_code latitude longitude accuracy_radius\r\n0 1.0.0.0/24 2077456.0 2077456.0 NaN 0 0 NaN -33.4940 143.2104 1000.0\r\n1 1.0.1.0/24 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0\r\n2 1.0.2.0/23 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0\r\n3 1.0.4.0/22 2147714.0 2077456.0 NaN 0 0 2000 -33.8715 151.2006 1000.0\r\n4 1.0.8.0/21 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0\r\n5 1.0.16.0/20 1861060.0 1861060.0 NaN 0 0 NaN 35.6897 139.6895 500.0\r\n6 1.0.32.0/19 1814991.0 1814991.0 NaN 0 0 NaN 34.7732 113.7220 1000.0\r\n7 1.0.64.0/22 1862415.0 1861060.0 NaN 0 0 730-0851 34.3927 132.4501 5.0\r\n8 1.0.68.0/23 11818936.0 1861060.0 NaN 0 0 739-0424 34.2976 132.2898 20.0\r\n9 1.0.70.0/25 1856520.0 1861060.0 NaN 0 0 730-0011 34.3978 132.4525 10.0\r\n aa_startip aa_subnet aa_startip_int aa_endip aa_endip_int aa_subnetmask\r\n0 1.0.0.0 24 16777216 1.0.0.255 16777471 255.255.255.0\r\n1 1.0.1.0 24 16777472 1.0.1.255 16777727 255.255.255.0\r\n2 1.0.2.0 23 16777728 1.0.3.255 16778239 255.255.254.0\r\n3 1.0.4.0 22 16778240 1.0.7.255 16779263 255.255.252.0\r\n4 1.0.8.0 21 16779264 1.0.15.255 16781311 255.255.248.0\r\n5 1.0.16.0 20 16781312 1.0.31.255 16785407 255.255.240.0\r\n6 1.0.32.0 19 16785408 1.0.63.255 16793599 255.255.224.0\r\n7 1.0.64.0 22 16793600 1.0.67.255 16794623 255.255.252.0\r\n8 1.0.68.0 23 16794624 1.0.69.255 16795135 255.255.254.0\r\n9 1.0.70.0 25 16795136 1.0.70.127 16795263 255.255.255.128\r\n\r\n\r\nConvert CIDR notation IP addresses to start and end IP addresses along with subnet masks.\r\n\r\nThis function takes a list or pandas DataFrame/Series containing CIDR notation IP addresses\r\nand returns a DataFrame with the following columns:\r\n\r\n- 'aa_startip': The starting IP address in string format.\r\n- \"aa_subnet\": The subnet mask in integer format (uint8).\r\n- 'aa_endip': The ending IP address in string format.\r\n- 'aa_startip_int': The starting IP address in integer format (uint32).\r\n- 'aa_endip_int': The ending IP address in integer format (uint32).\r\n- 'aa_subnetmask': The subnet mask in string format.\r\n\r\nParameters:\r\n-----------\r\ndf_series_list : list, pandas.Series, or pandas.DataFrame\r\n\tThe input data containing CIDR notation IP addresses.\r\ncolumn : str, optional (default=\"network\")\r\n\tThe name of the column containing the CIDR notation IP addresses if df_series_list is a DataFrame.\r\n\r\nReturns:\r\n--------\r\npandas.DataFrame\r\n\tA DataFrame with the converted IP addresses and subnet masks.\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "High speed conversion of IP addresses represented in CIDR notation into their corresponding start and end IPs, along with their respective subnet masks.",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/cirdhighspeedcoverter"
},
"split_keywords": [
"cidr",
"convert"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "41364b5024df1a372a89f8ad227d6394f844a54ae26764911fcf93d0a3ef9ac3",
"md5": "a27e330d2da0e2e5f9f982caa226ad6f",
"sha256": "ca1890f2428f8badf42180d1ee9dfa4bb44a6453c1449457564b21d4acf703b8"
},
"downloads": -1,
"filename": "cirdhighspeedcoverter-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a27e330d2da0e2e5f9f982caa226ad6f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 25546,
"upload_time": "2023-09-08T04:42:18",
"upload_time_iso_8601": "2023-09-08T04:42:18.293639Z",
"url": "https://files.pythonhosted.org/packages/41/36/4b5024df1a372a89f8ad227d6394f844a54ae26764911fcf93d0a3ef9ac3/cirdhighspeedcoverter-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "977286c072adf6962b66e976af6a14c55e3ccc58d5240cf242f05d396e7ebbee",
"md5": "ab7069314f1e246b9521efeb19a0d83b",
"sha256": "dac18006386334aa6f02101f8955788be6647d4f7ec1548290682c58822f1d77"
},
"downloads": -1,
"filename": "cirdhighspeedcoverter-0.10.tar.gz",
"has_sig": false,
"md5_digest": "ab7069314f1e246b9521efeb19a0d83b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25206,
"upload_time": "2023-09-08T04:42:20",
"upload_time_iso_8601": "2023-09-08T04:42:20.497394Z",
"url": "https://files.pythonhosted.org/packages/97/72/86c072adf6962b66e976af6a14c55e3ccc58d5240cf242f05d396e7ebbee/cirdhighspeedcoverter-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-08 04:42:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "cirdhighspeedcoverter",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numexpr",
"specs": []
},
{
"name": "numpy",
"specs": []
},
{
"name": "pandas",
"specs": []
}
],
"lcname": "cirdhighspeedcoverter"
}