Polars MaxMindDB Lookup Plugin
This plugin extends the functionality of Polars by providing methods to look up IP address information using MaxMind databases. It supports city, country, and ASN lookups.
Features
- City Lookup: Retrieves city-level information for a given IP address as a string.
- Country Lookup: Retrieves country-level information for a given IP address as a string.
- ASN Lookup: Retrieves ASN (Autonomous System Number) name for a given IP address as a string.
- Integration with Polars: Works seamlessly with Polars DataFrames, offering fast processing.
Requirements
- Python 3.8+
- Polars library
Install Polars with:
uv add polars
- MaxMindDB: Download and use the GeoIP2 databases provided by MaxMind (e.g., GeoLite2-City.mmdb, GeoLite2-Country.mmdb, GeoLite2-ASN.mmdb). See MaxMind for more details.
Installation
Add the plugin to your project. Install it directly from the repository or manually include the Python file.
uv add polars-maxminddb
Usage
Example Code
import polars as pl
from polars_maxminddb import ip_lookup_city, ip_lookup_country, ip_lookup_asn
# Example DataFrame with IP addresses
df = pl.DataFrame({
"ip_addresses": ["92.200.50.6", "195.90.212.198", "95.173.223.186", "121.37.156.226"],
})
# Perform city lookup
df = df.with_columns(
ip_lookup_city(df["ip_addresses"]).alias("city")
)
# Perform country lookup
df = df.with_columns(
ip_lookup_country(df["ip_addresses"]).alias("country")
)
# Perform ASN lookup
df = df.with_columns(
ip_lookup_asn(df["ip_addresses"]).alias("asn_name")
)
print(df)
Output
The output will include the city, country, and ASN name information as strings. For example:
shape: (4, 4)
┌────────────────┬───────────────────┬─────────┬─────────────────────────────────┐
│ ip ┆ city ┆ country ┆ asn_name │
│ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str ┆ str │
╞════════════════╪═══════════════════╪═════════╪═════════════════════════════════╡
│ 92.200.50.6 ┆ Sundern ┆ Germany ┆ Plusnet GmbH │
│ 195.90.212.198 ┆ Frankfurt am Main ┆ Germany ┆ EVANZO e-commerce GmbH │
│ 95.173.223.186 ┆ Lima ┆ Peru ┆ Datacamp Limited │
│ 121.37.156.226 ┆ ┆ China ┆ Huawei Cloud Service data cent… │
└────────────────┴───────────────────┴─────────┴─────────────────────────────────┘
Metadata
Release files for polars-maxminddb 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| polars_maxminddb-0.2.3.tar.gz | 18.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| polars_maxminddb-0.2.3-cp38-abi3-manylinux_2_34_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.34+ x86-64 | Details |
Total release size: 3.9 MB
Release files / polars_maxminddb-0.2.3.tar.gz
| Download URL | polars_maxminddb-0.2.3.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62d8b46321fb14dd60fa75ca79b6f50b3895c65656d0444aaab53eb99c8400e5
|
|
BLAKE2b-256 checksum How to use checksums |
3e6a8cd6401b80e42a02e083dcb1df2cc09a76cbfc0789ddb492c3288bebda18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.7.8
|
Release files / polars_maxminddb-0.2.3-cp38-abi3-manylinux_2_34_x86_64.whl
| Download URL | polars_maxminddb-0.2.3-cp38-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | CPython 3.8 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
327ab16e7dfbe5637f8d000d5d120b628d6d23509acf6a60900e34fe7948ec59
|
|
BLAKE2b-256 checksum How to use checksums |
95f41242b2cb24abdb20df1325fa18905f69bd0e6abed4717f65cb18123374ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.7.8
|
Security for polars-maxminddb 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.