Name | stable-stats JSON |
Version |
0.1.4
JSON |
| download |
home_page | https://github.com/Chris-R030307/StaTable |
Summary | A Python package for beautifying statistical outputs into clean tables |
upload_time | 2025-10-16 16:30:52 |
maintainer | None |
docs_url | None |
author | Christopher Ren |
requires_python | >=3.8 |
license | MIT License
Copyright (c) 2024 Christopher Ren
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
statistics
scipy
statsmodels
tables
formatting
data analysis
|
VCS |
 |
bugtrack_url |
|
requirements |
numpy
pandas
scipy
statsmodels
openpyxl
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Stable
A Python package for beautifying statistical outputs from scipy, statsmodels, and other libraries into clean, publication-ready tables.
## Features
- **Automatic Detection**: Recognizes common statistical tests (t-tests, ANOVA, chi-square, regression, etc.)
- **Multiple Export Formats**: Markdown, Excel, HTML, and pandas DataFrame
- **Pretty Formatting**: Rounded decimals, significance stars, confidence intervals
- **Flexible Input**: Works with scipy.stats and statsmodels results
- **Easy to Use**: Simple API with methods like `.to_markdown()`, `.to_excel()`
## Installation
### From PyPI (recommended)
```bash
pip install stable-stats
```
### From source
```bash
git clone https://github.com/Chris-R030307/StaTable.git
cd StaTable
pip install -e .
```
### Development installation
```bash
git clone https://github.com/Chris-R030307/StaTable.git
cd StaTable
pip install -e ".[dev,test]"
```
### Dependencies
The package requires:
- Python 3.8+
- numpy >= 1.19.0
- pandas >= 1.3.0
- scipy >= 1.7.0
- statsmodels >= 0.12.0
- openpyxl >= 3.0.0 (for Excel export)
## Quick Start
```python
from scipy import stats
from stable import Stable
# Run a statistical test
result = stats.ttest_ind(group1, group2)
# Beautify the results
table = Stable(result)
# Export to different formats
print(table.to_markdown()) # Pretty table in console
table.to_excel("results.xlsx") # Export to Excel
html_output = table.to_html() # Get HTML string
```
## Examples
### T-test
```python
import numpy as np
from scipy import stats
from stable import Stable
# Generate sample data
np.random.seed(42)
group1 = np.random.normal(100, 15, 30)
group2 = np.random.normal(110, 15, 30)
# Run t-test
result = stats.ttest_ind(group1, group2)
# Beautify
stable = Stable(result)
print(stable.to_markdown())
```
Output:
```markdown
## Independent t-test
**Sample Size:** 30
## Results
| Statistic | Value | p-value | Significance |
|-----------|-------|---------|--------------|
| Test Statistic | -2.108 | 0.039* | * |
Effect Size: -2.108
```
### ANOVA
```python
# Generate data for 3 groups
group_a = np.random.normal(50, 10, 25)
group_b = np.random.normal(55, 10, 25)
group_c = np.random.normal(60, 10, 25)
# Run ANOVA
result = stats.f_oneway(group_a, group_b, group_c)
# Beautify
stable = Stable(result)
print(stable.to_markdown())
```
### Linear Regression
```python
import pandas as pd
import statsmodels.api as sm
from statsmodels.formula.api import ols
# Generate sample data
x = np.random.normal(0, 1, 100)
y = 2 * x + np.random.normal(0, 0.5, 100)
df = pd.DataFrame({'x': x, 'y': y})
# Run regression
model = ols('y ~ x', data=df).fit()
# Beautify
stable = Stable(model)
print(stable.to_markdown())
```
### Direct Analysis Methods
```python
# Direct t-test
stable = Stable.from_ttest(group1, group2)
# Direct ANOVA
stable = Stable.from_anova(group_a, group_b, group_c)
# Direct chi-square
observed = [20, 30, 25, 25]
expected = [25, 25, 25, 25]
stable = Stable.from_chi2(observed, expected)
```
## Supported Statistical Tests
### Scipy.stats
- t-tests (independent, paired, one-sample)
- ANOVA (one-way)
- Chi-square tests
- Kolmogorov-Smirnov tests
- Mann-Whitney U test
- Wilcoxon signed-rank test
- Kruskal-Wallis test
- Friedman test
### Statsmodels
- Linear regression
- ANOVA
- t-tests
- F-tests
- Contrast tests
## Export Formats
### Markdown
```python
markdown_output = stable.to_markdown(title="My Analysis")
print(markdown_output)
```
### Excel
```python
stable.to_excel("results.xlsx", sheet_name="Analysis")
```
### HTML
```python
html_output = stable.to_html(title="My Analysis", include_css=True)
```
### Pandas DataFrame
```python
df = stable.to_dataframe()
```
## API Reference
### Stable Class
#### Methods
- `to_markdown(title=None)`: Export to Markdown format
- `to_excel(filename, sheet_name="Statistical Results")`: Export to Excel
- `to_html(title=None, include_css=True)`: Export to HTML
- `to_dataframe()`: Export to pandas DataFrame
- `summary()`: Get brief summary of results
- `is_supported()`: Check if result type is supported
#### Properties
- `get_test_name()`: Get human-readable test name
- `get_statistic()`: Get test statistic(s)
- `get_p_value()`: Get p-value(s)
- `get_effect_size()`: Get effect size(s)
- `get_confidence_interval()`: Get confidence interval
- `get_sample_size()`: Get sample size information
- `get_degrees_of_freedom()`: Get degrees of freedom
- `get_coefficients()`: Get coefficient information (regression)
- `get_model_info()`: Get model information (regression)
#### Class Methods
- `Stable.from_ttest(group1, group2, **kwargs)`: Direct t-test
- `Stable.from_anova(*groups, **kwargs)`: Direct ANOVA
- `Stable.from_chi2(observed, expected=None, **kwargs)`: Direct chi-square
- `Stable.from_regression(model_result)`: From regression result
## Package Structure
```
stable/
├── __init__.py # Main package interface
├── core.py # Core Stable class
├── utils.py # Helper functions
├── adapters/ # Input adapters
│ ├── scipy_adapter.py # Scipy.stats adapter
│ └── statsmodels_adapter.py # Statsmodels adapter
└── exporters/ # Output exporters
├── markdown.py # Markdown exporter
├── excel.py # Excel exporter
└── html.py # HTML exporter
```
## Requirements
- Python 3.7+
- numpy >= 1.19.0
- pandas >= 1.3.0
- scipy >= 1.7.0
- statsmodels >= 0.12.0
- openpyxl >= 3.0.0 (for Excel export)
## Development
### Setup Development Environment
```bash
git clone <repository-url>
cd stable
pip install -e ".[dev]"
```
### Run Tests
```bash
pytest
```
### Run Example
```bash
python example_usage.py
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
## License
MIT License - see LICENSE file for details.
## Future Features
- Support for more statistical libraries (pingouin, sklearn)
- Interactive tables (Plotly dashboards)
- Custom templates (APA style, clinical reports)
- LaTeX export
- More effect size calculations
- Power analysis integration
Raw data
{
"_id": null,
"home_page": "https://github.com/Chris-R030307/StaTable",
"name": "stable-stats",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Christopher Ren <chris.ren@emory.edu>",
"keywords": "statistics, scipy, statsmodels, tables, formatting, data analysis",
"author": "Christopher Ren",
"author_email": "Christopher Ren <chris.ren@emory.edu>",
"download_url": "https://files.pythonhosted.org/packages/b2/de/162ebf60e09d7ee305157a99ec3b8990ebd2682e43b4278f89a4c8583e65/stable_stats-0.1.4.tar.gz",
"platform": null,
"description": "# Stable\n\nA Python package for beautifying statistical outputs from scipy, statsmodels, and other libraries into clean, publication-ready tables.\n\n## Features\n\n- **Automatic Detection**: Recognizes common statistical tests (t-tests, ANOVA, chi-square, regression, etc.)\n- **Multiple Export Formats**: Markdown, Excel, HTML, and pandas DataFrame\n- **Pretty Formatting**: Rounded decimals, significance stars, confidence intervals\n- **Flexible Input**: Works with scipy.stats and statsmodels results\n- **Easy to Use**: Simple API with methods like `.to_markdown()`, `.to_excel()`\n\n## Installation\n\n### From PyPI (recommended)\n\n```bash\npip install stable-stats\n```\n\n### From source\n\n```bash\ngit clone https://github.com/Chris-R030307/StaTable.git\ncd StaTable\npip install -e .\n```\n\n### Development installation\n\n```bash\ngit clone https://github.com/Chris-R030307/StaTable.git\ncd StaTable\npip install -e \".[dev,test]\"\n```\n\n### Dependencies\n\nThe package requires:\n- Python 3.8+\n- numpy >= 1.19.0\n- pandas >= 1.3.0\n- scipy >= 1.7.0\n- statsmodels >= 0.12.0\n- openpyxl >= 3.0.0 (for Excel export)\n\n## Quick Start\n\n```python\nfrom scipy import stats\nfrom stable import Stable\n\n# Run a statistical test\nresult = stats.ttest_ind(group1, group2)\n\n# Beautify the results\ntable = Stable(result)\n\n# Export to different formats\nprint(table.to_markdown()) # Pretty table in console\ntable.to_excel(\"results.xlsx\") # Export to Excel\nhtml_output = table.to_html() # Get HTML string\n```\n\n## Examples\n\n### T-test\n\n```python\nimport numpy as np\nfrom scipy import stats\nfrom stable import Stable\n\n# Generate sample data\nnp.random.seed(42)\ngroup1 = np.random.normal(100, 15, 30)\ngroup2 = np.random.normal(110, 15, 30)\n\n# Run t-test\nresult = stats.ttest_ind(group1, group2)\n\n# Beautify\nstable = Stable(result)\nprint(stable.to_markdown())\n```\n\nOutput:\n```markdown\n## Independent t-test\n\n**Sample Size:** 30\n\n## Results\n\n| Statistic | Value | p-value | Significance |\n|-----------|-------|---------|--------------|\n| Test Statistic | -2.108 | 0.039* | * |\n\nEffect Size: -2.108\n```\n\n### ANOVA\n\n```python\n# Generate data for 3 groups\ngroup_a = np.random.normal(50, 10, 25)\ngroup_b = np.random.normal(55, 10, 25)\ngroup_c = np.random.normal(60, 10, 25)\n\n# Run ANOVA\nresult = stats.f_oneway(group_a, group_b, group_c)\n\n# Beautify\nstable = Stable(result)\nprint(stable.to_markdown())\n```\n\n### Linear Regression\n\n```python\nimport pandas as pd\nimport statsmodels.api as sm\nfrom statsmodels.formula.api import ols\n\n# Generate sample data\nx = np.random.normal(0, 1, 100)\ny = 2 * x + np.random.normal(0, 0.5, 100)\ndf = pd.DataFrame({'x': x, 'y': y})\n\n# Run regression\nmodel = ols('y ~ x', data=df).fit()\n\n# Beautify\nstable = Stable(model)\nprint(stable.to_markdown())\n```\n\n### Direct Analysis Methods\n\n```python\n# Direct t-test\nstable = Stable.from_ttest(group1, group2)\n\n# Direct ANOVA\nstable = Stable.from_anova(group_a, group_b, group_c)\n\n# Direct chi-square\nobserved = [20, 30, 25, 25]\nexpected = [25, 25, 25, 25]\nstable = Stable.from_chi2(observed, expected)\n```\n\n## Supported Statistical Tests\n\n### Scipy.stats\n- t-tests (independent, paired, one-sample)\n- ANOVA (one-way)\n- Chi-square tests\n- Kolmogorov-Smirnov tests\n- Mann-Whitney U test\n- Wilcoxon signed-rank test\n- Kruskal-Wallis test\n- Friedman test\n\n### Statsmodels\n- Linear regression\n- ANOVA\n- t-tests\n- F-tests\n- Contrast tests\n\n## Export Formats\n\n### Markdown\n```python\nmarkdown_output = stable.to_markdown(title=\"My Analysis\")\nprint(markdown_output)\n```\n\n### Excel\n```python\nstable.to_excel(\"results.xlsx\", sheet_name=\"Analysis\")\n```\n\n### HTML\n```python\nhtml_output = stable.to_html(title=\"My Analysis\", include_css=True)\n```\n\n### Pandas DataFrame\n```python\ndf = stable.to_dataframe()\n```\n\n## API Reference\n\n### Stable Class\n\n#### Methods\n\n- `to_markdown(title=None)`: Export to Markdown format\n- `to_excel(filename, sheet_name=\"Statistical Results\")`: Export to Excel\n- `to_html(title=None, include_css=True)`: Export to HTML\n- `to_dataframe()`: Export to pandas DataFrame\n- `summary()`: Get brief summary of results\n- `is_supported()`: Check if result type is supported\n\n#### Properties\n\n- `get_test_name()`: Get human-readable test name\n- `get_statistic()`: Get test statistic(s)\n- `get_p_value()`: Get p-value(s)\n- `get_effect_size()`: Get effect size(s)\n- `get_confidence_interval()`: Get confidence interval\n- `get_sample_size()`: Get sample size information\n- `get_degrees_of_freedom()`: Get degrees of freedom\n- `get_coefficients()`: Get coefficient information (regression)\n- `get_model_info()`: Get model information (regression)\n\n#### Class Methods\n\n- `Stable.from_ttest(group1, group2, **kwargs)`: Direct t-test\n- `Stable.from_anova(*groups, **kwargs)`: Direct ANOVA\n- `Stable.from_chi2(observed, expected=None, **kwargs)`: Direct chi-square\n- `Stable.from_regression(model_result)`: From regression result\n\n## Package Structure\n\n```\nstable/\n\u251c\u2500\u2500 __init__.py # Main package interface\n\u251c\u2500\u2500 core.py # Core Stable class\n\u251c\u2500\u2500 utils.py # Helper functions\n\u251c\u2500\u2500 adapters/ # Input adapters\n\u2502 \u251c\u2500\u2500 scipy_adapter.py # Scipy.stats adapter\n\u2502 \u2514\u2500\u2500 statsmodels_adapter.py # Statsmodels adapter\n\u2514\u2500\u2500 exporters/ # Output exporters\n \u251c\u2500\u2500 markdown.py # Markdown exporter\n \u251c\u2500\u2500 excel.py # Excel exporter\n \u2514\u2500\u2500 html.py # HTML exporter\n```\n\n## Requirements\n\n- Python 3.7+\n- numpy >= 1.19.0\n- pandas >= 1.3.0\n- scipy >= 1.7.0\n- statsmodels >= 0.12.0\n- openpyxl >= 3.0.0 (for Excel export)\n\n## Development\n\n### Setup Development Environment\n\n```bash\ngit clone <repository-url>\ncd stable\npip install -e \".[dev]\"\n```\n\n### Run Tests\n\n```bash\npytest\n```\n\n### Run Example\n\n```bash\npython example_usage.py\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Future Features\n\n- Support for more statistical libraries (pingouin, sklearn)\n- Interactive tables (Plotly dashboards)\n- Custom templates (APA style, clinical reports)\n- LaTeX export\n- More effect size calculations\n- Power analysis integration\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2024 Christopher Ren\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "A Python package for beautifying statistical outputs into clean tables",
"version": "0.1.4",
"project_urls": {
"Bug Tracker": "https://github.com/Chris-R030307/StaTable/issues",
"Changelog": "https://github.com/Chris-R030307/StaTable/blob/main/CHANGELOG.md",
"Documentation": "https://stable.readthedocs.io/",
"Homepage": "https://github.com/Chris-R030307/StaTable",
"Repository": "https://github.com/Chris-R030307/StaTable"
},
"split_keywords": [
"statistics",
" scipy",
" statsmodels",
" tables",
" formatting",
" data analysis"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a7b6df5b976ada831a2968a1d0af69d25a28cf74856560772bb20ad7955b5158",
"md5": "3641747bf0828372fef3bcdc7966c91e",
"sha256": "c9b1e520a96c748babf97e75bc9d40babdf8b454242afa9c2f030d1363ab924d"
},
"downloads": -1,
"filename": "stable_stats-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3641747bf0828372fef3bcdc7966c91e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 22808,
"upload_time": "2025-10-16T16:30:51",
"upload_time_iso_8601": "2025-10-16T16:30:51.915183Z",
"url": "https://files.pythonhosted.org/packages/a7/b6/df5b976ada831a2968a1d0af69d25a28cf74856560772bb20ad7955b5158/stable_stats-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b2de162ebf60e09d7ee305157a99ec3b8990ebd2682e43b4278f89a4c8583e65",
"md5": "b9b1235788a1b40c6707371a6602193a",
"sha256": "6c90c649c5eb41c310d4340d1cdfeb4d3e64e48fe0ade6d73b2d94f2db502e4c"
},
"downloads": -1,
"filename": "stable_stats-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "b9b1235788a1b40c6707371a6602193a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 26919,
"upload_time": "2025-10-16T16:30:52",
"upload_time_iso_8601": "2025-10-16T16:30:52.978756Z",
"url": "https://files.pythonhosted.org/packages/b2/de/162ebf60e09d7ee305157a99ec3b8990ebd2682e43b4278f89a4c8583e65/stable_stats-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-16 16:30:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Chris-R030307",
"github_project": "StaTable",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.19.0"
]
]
},
{
"name": "pandas",
"specs": [
[
">=",
"1.3.0"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.7.0"
]
]
},
{
"name": "statsmodels",
"specs": [
[
">=",
"0.12.0"
]
]
},
{
"name": "openpyxl",
"specs": [
[
">=",
"3.0.0"
]
]
}
],
"lcname": "stable-stats"
}