No project description provided
Project description
polars-xml
This is a very simple Polars plugin that allows querying xml in a string column with XPath.
It has just one function, xpath, which accepts an expression and a valid xpath statement.
import polars as pl
import polars_xml as px
rows = []
for i in range(1000):
sample_xml = f"""
<foo>
<bar quux="hello from quux {i}">hello from bar {i}</bar>
<baz xyzzy="hello from xyzzy {i}">hello from baz {i}</baz>
</foo>
"""
rows.append(
{
"index": i,
"xml_data": sample_xml,
}
)
df = pl.DataFrame(rows).select(
index=pl.col("index"),
bar=px.xpath(pl.col("xml_data"), "//foo//bar"),
baz=px.xpath(pl.col("xml_data"), "//foo//baz"),
quux=px.xpath(pl.col("xml_data"), "//foo//bar/@quux"),
xyzzy=px.xpath(pl.col("xml_data"), "//foo//baz/@xyzzy"),
missing=px.xpath(pl.col("xml_data"), "//foo//wow"),
)
print(df)
shape: (1_000, 6)
┌───────┬────────────────────────┬────────────────────────┬─────────────────────────┬──────────────────────────┬───────────┐
│ index ┆ bar ┆ baz ┆ quux ┆ xyzzy ┆ missing │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ list[str] ┆ list[str] ┆ list[str] ┆ list[str] ┆ list[str] │
╞═══════╪════════════════════════╪════════════════════════╪═════════════════════════╪══════════════════════════╪═══════════╡
│ 0 ┆ ["hello from bar 0"] ┆ ["hello from baz 0"] ┆ ["hello from quux 0"] ┆ ["hello from xyzzy 0"] ┆ [] │
│ 1 ┆ ["hello from bar 1"] ┆ ["hello from baz 1"] ┆ ["hello from quux 1"] ┆ ["hello from xyzzy 1"] ┆ [] │
│ 2 ┆ ["hello from bar 2"] ┆ ["hello from baz 2"] ┆ ["hello from quux 2"] ┆ ["hello from xyzzy 2"] ┆ [] │
│ 3 ┆ ["hello from bar 3"] ┆ ["hello from baz 3"] ┆ ["hello from quux 3"] ┆ ["hello from xyzzy 3"] ┆ [] │
│ 4 ┆ ["hello from bar 4"] ┆ ["hello from baz 4"] ┆ ["hello from quux 4"] ┆ ["hello from xyzzy 4"] ┆ [] │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ 995 ┆ ["hello from bar 995"] ┆ ["hello from baz 995"] ┆ ["hello from quux 995"] ┆ ["hello from xyzzy 995"] ┆ [] │
│ 996 ┆ ["hello from bar 996"] ┆ ["hello from baz 996"] ┆ ["hello from quux 996"] ┆ ["hello from xyzzy 996"] ┆ [] │
│ 997 ┆ ["hello from bar 997"] ┆ ["hello from baz 997"] ┆ ["hello from quux 997"] ┆ ["hello from xyzzy 997"] ┆ [] │
│ 998 ┆ ["hello from bar 998"] ┆ ["hello from baz 998"] ┆ ["hello from quux 998"] ┆ ["hello from xyzzy 998"] ┆ [] │
│ 999 ┆ ["hello from bar 999"] ┆ ["hello from baz 999"] ┆ ["hello from quux 999"] ┆ ["hello from xyzzy 999"] ┆ [] │
└───────┴────────────────────────┴────────────────────────┴─────────────────────────┴──────────────────────────┴───────────┘
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polars_xml-0.3.1.tar.gz.
File metadata
- Download URL: polars_xml-0.3.1.tar.gz
- Upload date:
- Size: 32.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1486b301bab4f1944cf5e2601914d659c779e2993ad0865c267534f0c0c0f5c
|
|
| MD5 |
9ecbe229950ec3e08e4c7dc270f145c6
|
|
| BLAKE2b-256 |
b5e0bf0a0beb2ca7bd8dbb1ce7d87a06242d826f83f6dbe21784797ca156b636
|
File details
Details for the file polars_xml-0.3.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: polars_xml-0.3.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
562aaaf169b40788aa90e06de1e50c8349931dbfd6a77c0ca002eb85a8fd378e
|
|
| MD5 |
35f1922f1cd9ae8b80ed3a9813b33b1d
|
|
| BLAKE2b-256 |
f371d4253ba17a61201ced2d78cc2cccca050b2e1acc98d66fe35c3c2371ce2e
|
File details
Details for the file polars_xml-0.3.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: polars_xml-0.3.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d534d043f54fb02cb80d4a9c2619b3f8b363d6ab0857042e02098caaa031f5bd
|
|
| MD5 |
fecf295b7392202a8a685a7f3764e923
|
|
| BLAKE2b-256 |
6fa79e49cb0fa2b3391a50fc7cc105537628c9d115619e046832aa0035db96de
|
File details
Details for the file polars_xml-0.3.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: polars_xml-0.3.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc3219348d236171abb2750a69e36b09eb48b7b99e5f14ef83a88938d38583ec
|
|
| MD5 |
108ff952b58cc536fe76cd915d099e0b
|
|
| BLAKE2b-256 |
2515b9684be683b7288a25fe2e3410a865873411cf31063bb174c7495ff058d4
|
File details
Details for the file polars_xml-0.3.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: polars_xml-0.3.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b64789712c80bce68651027c134975c330c72cd61e185c790a1fd0c174947ee
|
|
| MD5 |
e714f6a848304be4ddfcb985f55b77d8
|
|
| BLAKE2b-256 |
f05ec053bc06abed675ec9092185c2d9148f9bf21f91a05c6afcd1956dff09fb
|