# 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
<img src="https://github.com/thevgergroup/ipy-compare/blob/main/docs/assets/each-ipy-compare.png?raw=true" alt="Each Column" width="700" height="200">
#### Overall Row
<img src="https://github.com/thevgergroup/ipy-compare/blob/main/docs/assets/overall-ipy-compare.png?raw=true" alt="Overall Row" width="700" height="200">
---
## Installation
```bash
pip install ipy-compare
```
---
## Usage
### Import and Initialize
```python
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:
```python
# 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:
```python
# 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:
```python
# 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:
```python
!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:
```python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/thevgergroup/ipy-compare",
"name": "ipy-compare",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.11,>=3.10",
"maintainer_email": null,
"keywords": "data, analysis, visualization, pandas, ipython, panel, google-colab, jupyterlab",
"author": "patrick o'leary",
"author_email": "pjaol@pjaol.com",
"download_url": "https://files.pythonhosted.org/packages/fe/2b/edb1f2cf95dc2eb62776aef4acb751997127fbd42fbc08136f9652336573/ipy_compare-0.3.tar.gz",
"platform": null,
"description": "# ipy-compare\n\n`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. \nIdeally used for tagging or for labeling data in a pandas DataFrame.\n\n## Features\n- **Row and Column Comparison**: Supports both overall row-level measures and column-specific measures.\n- **Pagination**: Navigate through rows using custom indices or iterators.\n- **Repeatable Sampling**: Use a fixed random seed for consistent sampling.\n- **Branding**: Add customizable branding to the footer, including a linkable logo and text.\n- **Interactive Radio Buttons**: Visual indicators for selected measures.\n- **Colab Compatible**: Works seamlessly in Google Colab notebooks.\n\n### Example:\nWe support two different ways to use ipy-compare.\n\n1. **Each Column**: Use a measure for each column.\n2. **Overall Row**: Use a measure for the entire row.\n\nWhere you can specify the questions you want to ask for each column or for the entire row.\n\n#### Each Column\n<img src=\"https://github.com/thevgergroup/ipy-compare/blob/main/docs/assets/each-ipy-compare.png?raw=true\" alt=\"Each Column\" width=\"700\" height=\"200\">\n\n#### Overall Row\n<img src=\"https://github.com/thevgergroup/ipy-compare/blob/main/docs/assets/overall-ipy-compare.png?raw=true\" alt=\"Overall Row\" width=\"700\" height=\"200\">\n\n---\n\n## Installation\n\n```bash\npip install ipy-compare\n```\n\n---\n\n## Usage\n\n### Import and Initialize\n\n```python\nfrom ipy_compare import Compare\nimport pandas as pd\nimport panel as pn # Required for notebook/colab display\n\n# Sample DataFrame\ndata = {\n 'Column1': ['A', 'B', 'C'],\n 'Column2': ['X', 'Y', 'Z'],\n 'Column3': ['Apple', 'Fish swimming', 'Vrooom car']\n}\ndf = pd.DataFrame(data)\n\n# Define measures\nmeasures = {\n \"overall\": [\"Good\", \"Bad\"],\n \"each\": [\"Better\", \"Worse\", \"Neutral\"]\n}\n\n# Initialize Compare\ntool = Compare(df, columns=[\"Column1\", \"Column3\"], measures=measures)\n\n# Display the tool\ntool.servable()\n```\n\n---\n\n### Navigation and Interaction\n1. Navigate between rows using the `Previous` and `Submit & Next` buttons.\n2. Use the radio buttons to select measures for each column or for the overall row.\n3. Submit measurements using either the `Submit` button or `Submit & Next` to move to the next row.\n4. All measurements are captured and can be retrieved programmatically.\n\n---\n\n### Custom Pagination\nTo specify a subset of rows or custom order:\n\n```python\n# Custom row order\ncustom_order = [2, 0, 1]\n\n# Initialize Compare with custom pagination\ntool = Compare(df, columns=[\"Column1\", \"Column3\"], measures=measures, pagination=custom_order)\ntool.servable()\n```\n\n---\n\n### Repeatable Sampling\nTo use random sampling with a fixed seed:\n\n```python\n# Get a random sample of rows\nsampled_indices = Compare.sample_indices(df, n=2, seed=42)\n\n# Initialize Compare with sampled indices\ntool = Compare(df, columns=[\"Column1\", \"Column3\"], measures=measures, pagination=sampled_indices)\ntool.servable()\n```\n\n---\n\n### Retrieve Measurements\nOnce interactions are complete, retrieve the captured measurements:\n\n```python\n# Get measurements as a DataFrame\nmeasurements = tool.get_measurements()\nprint(measurements)\n```\n\n**Example Output:**\n\n| row_index | column | value | measure | type |\n|-----------|----------|----------------|-----------|---------|\n| 0 | None | None | Good | overall |\n| 0 | Column1 | A | Better | column |\n| 0 | Column3 | Apple | Neutral | column |\n| 1 | None | None | Bad | overall |\n| 1 | Column1 | B | Worse | column |\n| 1 | Column3 | Fish swimming | Neutral | column |\n\n---\n\n## Google Colab Usage\nWhen using in Google Colab, make sure to run these commands first:\n\n```python\n!pip install ipy-compare panel\n```\n\nThe tool is fully compatible with Google Colab and will work the same way as in Jupyter notebooks.\n\n---\n\n## Advanced Options\n\n### Custom Measures\nDefine your own measure categories:\n\n```python\nmeasures = {\n \"overall\": [\"Excellent\", \"Poor\"],\n \"each\": [\"Correct\", \"Incorrect\", \"Not Sure\"]\n}\n```\n\n---\n\n## Contributing\nContributions are welcome! Please fork the repository and submit a pull request with your changes.\n\n---\n\n## License\nThis project is licensed under the MIT License.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": null,
"version": "0.3",
"project_urls": {
"Homepage": "https://github.com/thevgergroup/ipy-compare",
"Repository": "https://github.com/thevgergroup/ipy-compare"
},
"split_keywords": [
"data",
" analysis",
" visualization",
" pandas",
" ipython",
" panel",
" google-colab",
" jupyterlab"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8e614f49919339ba712cbe7d1db37aa58f01cd293a7f050303818c06b140434e",
"md5": "b4fe1a35f814a0ea0844a23cadd02a58",
"sha256": "fd59ecd80b53dedd0c95944ff8792d680261cec6bbecc7331e72aa7ca904420d"
},
"downloads": -1,
"filename": "ipy_compare-0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b4fe1a35f814a0ea0844a23cadd02a58",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.11,>=3.10",
"size": 89805,
"upload_time": "2024-12-14T05:02:55",
"upload_time_iso_8601": "2024-12-14T05:02:55.269664Z",
"url": "https://files.pythonhosted.org/packages/8e/61/4f49919339ba712cbe7d1db37aa58f01cd293a7f050303818c06b140434e/ipy_compare-0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fe2bedb1f2cf95dc2eb62776aef4acb751997127fbd42fbc08136f9652336573",
"md5": "a66c63711fe8cf5531f0eb072618d12d",
"sha256": "beaf33d3ee30eb16814e333673e8d4c7433a4e07b68beb63001b142af652f2e0"
},
"downloads": -1,
"filename": "ipy_compare-0.3.tar.gz",
"has_sig": false,
"md5_digest": "a66c63711fe8cf5531f0eb072618d12d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.11,>=3.10",
"size": 91165,
"upload_time": "2024-12-14T05:02:58",
"upload_time_iso_8601": "2024-12-14T05:02:58.158229Z",
"url": "https://files.pythonhosted.org/packages/fe/2b/edb1f2cf95dc2eb62776aef4acb751997127fbd42fbc08136f9652336573/ipy_compare-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-14 05:02:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thevgergroup",
"github_project": "ipy-compare",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ipy-compare"
}