Utilities for working with EVM data in polars
Project description
Polars EVM
Polars EVM adds the evm namespace to polars on dataframes, lazyframes, series, and expressions.
This namespace has lots of functions for processing EVM data:
- binary ↔ hex conversions
- keccak
- abi encoding [TODO]
- rlp encoding [TODO]
Installation
pip install polars_evm
Usage
Just import polars_evm and then the evm namespace will be registered to polars.
import polars as pl
import polars_evm
addresses = [
b'\xda\xc1\x7f\x95\x8d.\xe5#\xa2 b\x06\x99E\x97\xc1=\x83\x1e\xc7',
b'\xa0\xb8i\x91\xc6!\x8b6\xc1\xd1\x9dJ.\x9e\xb0\xce6\x06\xebH',
b'_\x98\x80ZN\x8b\xe2U\xa3(\x80\xfd\xec\x7fg(\xc6V\x8b\xa0'
]
series = pl.Series('address', addresses)
df = pl.DataFrame(series)
print('hex series:', series.evm.binary_to_hex())
print('hex df:', df.evm.binary_to_hex())
print('hex expr:', df.select(pl.col('address').evm.binary_to_hex()))
output:
hex series: shape: (3,)
Series: 'address' [str]
[
"0xdac17f958d2e…
"0xa0b86991c621…
"0x5f98805a4e8b…
]
hex df: shape: (3, 1)
┌───────────────────────────────────┐
│ address │
│ --- │
│ str │
╞═══════════════════════════════════╡
│ 0xdac17f958d2ee523a2206206994597… │
│ 0xa0b86991c6218b36c1d19d4a2e9eb0… │
│ 0x5f98805a4e8be255a32880fdec7f67… │
└───────────────────────────────────┘
hex expr: shape: (3, 1)
┌───────────────────────────────────┐
│ literal │
│ --- │
│ str │
╞═══════════════════════════════════╡
│ 0xdac17f958d2ee523a2206206994597… │
│ 0xa0b86991c6218b36c1d19d4a2e9eb0… │
│ 0x5f98805a4e8be255a32880fdec7f67… │
└───────────────────────────────────┘
List of namespace entries
# DataFrame namespace
df.evm.binary_to_hex(prefix=True, columns=None)
df.evm.hex_to_binary(prefix=True, columns=None)
# LazyFrame namespace
lf.evm.binary_to_hex(prefix=True, columns=None)
lf.evm.hex_to_binary(prefix=True, columns=None)
# Series namespace
series.evm.binary_to_hex(prefix=True)
series.evm.hex_to_binary(prefix=True)
series.evm.keccak(output='hex', text=False)
# Expression namespace
pl.Expr.evm.binary_to_hex(prefix=True)
pl.Expr.evm.hex_to_binary(prefix=True)
pl.Expr.evm.keccak(output='hex', text=False)
Additional utilities
Beyond the evm namespace, polars_evm has the following utilities:
set_column_display_width(): set display width so that it fully displays tx hashes in jupyter notebooks and other printouts
TODO
- use efficient rust implementations where possible
- abi encoding
- rlp encoding
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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_evm-0.2.0.tar.gz.
File metadata
- Download URL: polars_evm-0.2.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9717bc2dc07b3e2c5c4ec8a8fe928d0e5caf80aeff2f5c3c4eca2d2425351a6f
|
|
| MD5 |
2169aaf7a89f0f63a29302fde846bbc0
|
|
| BLAKE2b-256 |
e5b302b4bbde9d1a0fb52cee23d23ec80029d1eea9414c5acaa204b06cb2c402
|
File details
Details for the file polars_evm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: polars_evm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e628f6b213c5e883b5eb18b1df20345f74d5a20ebe047af4ffb611030cdb2a62
|
|
| MD5 |
d4445f08369594d220fc8b8e344d4c62
|
|
| BLAKE2b-256 |
7046cad25f54b5b1055588c1f28562e347d804a991c848b1ebf7473f7658653e
|