No project description provided
Project description
ipy-compare
ipy-compare is an interactive tool designed for use in Jupyter notebooks and Google Colab, enabling users to visually compare rows and columns of a DataFrame.
Ideally used for tagging or for labeling data in a pandas DataFrame.
Features
- Row and Column Comparison: Supports both overall row-level measures and column-specific measures.
- Pagination: Navigate through rows using custom indices or iterators.
- Repeatable Sampling: Use a fixed random seed for consistent sampling.
- Branding: Add customizable branding to the footer, including a linkable logo and text.
- Interactive Radio Buttons: Visual indicators for selected measures.
- Colab Compatible: Works seamlessly in Google Colab notebooks.
Example:
We support two different ways to use ipy-compare.
- Each Column: Use a measure for each column.
- Overall Row: Use a measure for the entire row.
Where you can specify the questions you want to ask for each column or for the entire row.
Each Column
Overall Row
Installation
pip install ipy-compare
Usage
Import and Initialize
from ipy_compare import Compare
import pandas as pd
import panel as pn # Required for notebook/colab display
# Sample DataFrame
data = {
'Column1': ['A', 'B', 'C'],
'Column2': ['X', 'Y', 'Z'],
'Column3': ['Apple', 'Fish swimming', 'Vrooom car']
}
df = pd.DataFrame(data)
# Define measures
measures = {
"overall": ["Good", "Bad"],
"each": ["Better", "Worse", "Neutral"]
}
# Initialize Compare
tool = Compare(df, columns=["Column1", "Column3"], measures=measures)
# Display the tool
tool.servable()
Navigation and Interaction
- Navigate between rows using the
PreviousandSubmit & Nextbuttons. - Use the radio buttons to select measures for each column or for the overall row.
- Submit measurements using either the
Submitbutton orSubmit & Nextto move to the next row. - All measurements are captured and can be retrieved programmatically.
Custom Pagination
To specify a subset of rows or custom order:
# Custom row order
custom_order = [2, 0, 1]
# Initialize Compare with custom pagination
tool = Compare(df, columns=["Column1", "Column3"], measures=measures, pagination=custom_order)
tool.servable()
Repeatable Sampling
To use random sampling with a fixed seed:
# Get a random sample of rows
sampled_indices = Compare.sample_indices(df, n=2, seed=42)
# Initialize Compare with sampled indices
tool = Compare(df, columns=["Column1", "Column3"], measures=measures, pagination=sampled_indices)
tool.servable()
Retrieve Measurements
Once interactions are complete, retrieve the captured measurements:
# Get measurements as a DataFrame
measurements = tool.get_measurements()
print(measurements)
Example Output:
| row_index | column | value | measure | type |
|---|---|---|---|---|
| 0 | None | None | Good | overall |
| 0 | Column1 | A | Better | column |
| 0 | Column3 | Apple | Neutral | column |
| 1 | None | None | Bad | overall |
| 1 | Column1 | B | Worse | column |
| 1 | Column3 | Fish swimming | Neutral | column |
Google Colab Usage
When using in Google Colab, make sure to run these commands first:
!pip install ipy-compare panel
The tool is fully compatible with Google Colab and will work the same way as in Jupyter notebooks.
Advanced Options
Custom Measures
Define your own measure categories:
measures = {
"overall": ["Excellent", "Poor"],
"each": ["Correct", "Incorrect", "Not Sure"]
}
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
License
This project is licensed under the MIT License.
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 ipy_compare-0.4.1.tar.gz.
File metadata
- Download URL: ipy_compare-0.4.1.tar.gz
- Upload date:
- Size: 91.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88934bd8a7b523d650b316658f35ecb6ff5d693f94be0e86edac0575392c8f6a
|
|
| MD5 |
63617f8ffb534907680f48a508124458
|
|
| BLAKE2b-256 |
f06870a33b96df7c6039e4f59b023e6d0ff4a465e2089321ca9b7abe35b1a0af
|
Provenance
The following attestation bundles were made for ipy_compare-0.4.1.tar.gz:
Publisher:
python-publish.yml on thevgergroup/ipy-compare
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipy_compare-0.4.1.tar.gz -
Subject digest:
88934bd8a7b523d650b316658f35ecb6ff5d693f94be0e86edac0575392c8f6a - Sigstore transparency entry: 833621640
- Sigstore integration time:
-
Permalink:
thevgergroup/ipy-compare@e306d5b1066c72e65976ec2c2aee1e8dcd95fcc1 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/thevgergroup
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e306d5b1066c72e65976ec2c2aee1e8dcd95fcc1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipy_compare-0.4.1-py3-none-any.whl.
File metadata
- Download URL: ipy_compare-0.4.1-py3-none-any.whl
- Upload date:
- Size: 89.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b72bead242a435927e1dbef954b1f71262c09b8bf369060f7321f60650ff7e55
|
|
| MD5 |
45f9ad71a10c2f585b74573193d4e751
|
|
| BLAKE2b-256 |
f6972448077add6998665ff0e051f44198dfffa22cda7989e6517d836ac6df91
|
Provenance
The following attestation bundles were made for ipy_compare-0.4.1-py3-none-any.whl:
Publisher:
python-publish.yml on thevgergroup/ipy-compare
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipy_compare-0.4.1-py3-none-any.whl -
Subject digest:
b72bead242a435927e1dbef954b1f71262c09b8bf369060f7321f60650ff7e55 - Sigstore transparency entry: 833621641
- Sigstore integration time:
-
Permalink:
thevgergroup/ipy-compare@e306d5b1066c72e65976ec2c2aee1e8dcd95fcc1 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/thevgergroup
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e306d5b1066c72e65976ec2c2aee1e8dcd95fcc1 -
Trigger Event:
push
-
Statement type: