slicer [alpha]
(Equal Contribution) Samuel Jenkins & Harsha Nori & Scott Lundberg
slicer wraps tensor-like objects and provides a uniform slicing interface via __getitem__.
It supports many data types including:
numpy | pandas | scipy | pytorch | list | tuple | dict
And enables upgraded slicing functionality on its objects:
# Handles non-integer indexes for slicing.
S(df)[:, ["Age", "Income"]]
# Handles nested slicing in one call.
S(nested_list)[..., :5]
It can also simultaneously slice many objects at once:
# Gets first elements of both objects.
S(first=df, second=ar)[0, :]
This package has 0 dependencies. Not even one.
Installation
Python 3.6+ | Linux, Mac, Windows
pip install slicer
Getting Started
Basic anonymous slicing:
from slicer import Slicer as S
li = [[1, 2, 3], [4, 5, 6]]
S(li)[:, 0:2].o
# [[1, 2], [4, 5]]
di = {'x': [1, 2, 3], 'y': [4, 5, 6]}
S(di)[:, 0:2].o
# {'x': [1, 2], 'y': [4, 5]}
Basic named slicing:
import pandas as pd
import numpy as np
df = pd.DataFrame({'A': [1, 3], 'B': [2, 4]})
ar = np.array([[5, 6], [7, 8]])
sliced = S(first=df, second=ar)[0, :]
sliced.first
# A 1
# B 2
# Name: 0, dtype: int64
sliced.second
# array([5, 6])
Real example:
from slicer import Slicer as S
from slicer import Alias as A
data = [[1, 2], [3, 4]]
values = [[5, 6], [7, 8]]
identifiers = ["id1", "id1"]
instance_names = ["r1", "r2"]
feature_names = ["f1", "f2"]
full_name = "A"
slicer = S(
data=data,
values=values,
# Aliases are objects that also function as slicing keys.
# A(obj, dim) where dim informs what dimension it can be sliced on.
identifiers=A(identifiers, 0),
instance_names=A(instance_names, 0),
feature_names=A(feature_names, 1),
full_name=full_name,
)
sliced = slicer[:, 1] # Tensor-like parallel slicing on all objects
assert sliced.data == [2, 4]
assert sliced.instance_names == ["r1", "r2"]
assert sliced.feature_names == "f2"
assert sliced.values == [6, 8]
sliced = slicer["r1", "f2"] # Example use of aliasing
assert sliced.data == 2
assert sliced.feature_names == "f2"
assert sliced.instance_names == "r1"
assert sliced.values == 6
Contact us
Raise an issue on GitHub, or contact us at interpret@microsoft.com
Metadata
Release files for slicer 0.0.8
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 | Actions |
|---|---|---|---|---|
| slicer-0.0.8.tar.gz | 14.9 kB | Without provenance | Details for slicer-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slicer-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for slicer-0.0.8-py3-none-any.whl |
Total release size: 30.1 kB
Release files / slicer-0.0.8.tar.gz
| Download URL | slicer-0.0.8.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e7553af73f0c0c2d355f4afcc3ecf97c6f2156fcf4593955c3f56cf6c4d6eb7
|
|
BLAKE2b-256 checksum How to use checksums |
d3f9b4bce2825b39b57760b361e6131a3dacee3d8951c58cb97ad120abb90317
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Release files / slicer-0.0.8-py3-none-any.whl
| Download URL | slicer-0.0.8-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c206258543aecd010d497dc2eca9d2805860a0b3758673903456b7df7934dc3
|
|
BLAKE2b-256 checksum How to use checksums |
63819ef641ff4e12cbcca30e54e72fb0951a2ba195d0cda0ba4100e532d929db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Security for slicer 0.0.8
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.