Skip to main content

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.

  1. Each Column: Use a measure for each column.
  2. 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

Each Column

Overall Row

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

  1. Navigate between rows using the Previous and Submit & Next buttons.
  2. Use the radio buttons to select measures for each column or for the overall row.
  3. Submit measurements using either the Submit button or Submit & Next to move to the next row.
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipy_compare-0.4.1.tar.gz (91.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipy_compare-0.4.1-py3-none-any.whl (89.9 kB view details)

Uploaded Python 3

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

Hashes for ipy_compare-0.4.1.tar.gz
Algorithm Hash digest
SHA256 88934bd8a7b523d650b316658f35ecb6ff5d693f94be0e86edac0575392c8f6a
MD5 63617f8ffb534907680f48a508124458
BLAKE2b-256 f06870a33b96df7c6039e4f59b023e6d0ff4a465e2089321ca9b7abe35b1a0af

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipy_compare-0.4.1.tar.gz:

Publisher: python-publish.yml on thevgergroup/ipy-compare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ipy_compare-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b72bead242a435927e1dbef954b1f71262c09b8bf369060f7321f60650ff7e55
MD5 45f9ad71a10c2f585b74573193d4e751
BLAKE2b-256 f6972448077add6998665ff0e051f44198dfffa22cda7989e6517d836ac6df91

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page