# dataframe2image
Convert pandas DataFrame to beautiful table images.
## Features
- Convert pandas DataFrame to high-quality table images
- Beautiful, customizable styling with CSS
- Support for various image formats (PNG, JPEG, WebP)
- Responsive table design
- Easy to use API
## Installation
```bash
pip install dataframe2image
```
After installation, you need to install Playwright browsers:
```bash
playwright install chromium
```
## Quick Start
```python
import pandas as pd
from dataframe2image import df_to_image
# Create a sample DataFrame
df = pd.DataFrame({
'Name': ['Alice', 'Bob', 'Charlie', 'Diana'],
'Age': [25, 30, 35, 28],
'City': ['New York', 'London', 'Tokyo', 'Paris'],
'Salary': [50000, 60000, 70000, 55000]
})
# Convert to image
df_to_image(df, output_path='table.png')
```
## Advanced Usage
```python
from dataframe2image import df_to_image, TableStyle
# Custom styling
style = TableStyle(
theme='dark',
font_family='Arial',
font_size=14,
border_color='#333',
header_bg_color='#4CAF50',
row_bg_colors=['#f9f9f9', '#ffffff']
)
df_to_image(
df,
output_path='styled_table.png',
style=style,
width=800,
height=600
)
```
## API Reference
### `df_to_image(df, output_path, style=None, width=None, height=None, format='png')`
Convert a pandas DataFrame to an image.
**Parameters:**
- `df` (pandas.DataFrame): The DataFrame to convert
- `output_path` (str): Path where the image will be saved
- `style` (TableStyle, optional): Custom styling options
- `width` (int, optional): Image width in pixels
- `height` (int, optional): Image height in pixels (auto if not specified)
- `format` (str): Image format ('png', 'jpeg', 'webp')
### `TableStyle`
Customization options for table appearance.
**Parameters:**
- `theme` (str): Theme name ('light', 'dark', 'minimal')
- `font_family` (str): Font family name
- `font_size` (int): Font size in pixels
- `border_color` (str): Border color (CSS color)
- `header_bg_color` (str): Header background color
- `row_bg_colors` (list): Alternating row background colors
## License
MIT License
Raw data
{
"_id": null,
"home_page": null,
"name": "dataframe2image",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "pandas, dataframe, table, image, screenshot",
"author": null,
"author_email": "nolan zhao <nolanzhao@126.com>",
"download_url": "https://files.pythonhosted.org/packages/50/9f/4dbe5ce02c3590c31c9b77983552f35771563ff1886716072fd9d4a49ebe/dataframe2image-0.2.0.tar.gz",
"platform": null,
"description": "# dataframe2image\n\nConvert pandas DataFrame to beautiful table images.\n\n## Features\n\n- Convert pandas DataFrame to high-quality table images\n- Beautiful, customizable styling with CSS\n- Support for various image formats (PNG, JPEG, WebP)\n- Responsive table design\n- Easy to use API\n\n## Installation\n\n```bash\npip install dataframe2image\n```\n\nAfter installation, you need to install Playwright browsers:\n\n```bash\nplaywright install chromium\n```\n\n## Quick Start\n\n```python\nimport pandas as pd\nfrom dataframe2image import df_to_image\n\n# Create a sample DataFrame\ndf = pd.DataFrame({\n 'Name': ['Alice', 'Bob', 'Charlie', 'Diana'],\n 'Age': [25, 30, 35, 28],\n 'City': ['New York', 'London', 'Tokyo', 'Paris'],\n 'Salary': [50000, 60000, 70000, 55000]\n})\n\n# Convert to image\ndf_to_image(df, output_path='table.png')\n```\n\n## Advanced Usage\n\n```python\nfrom dataframe2image import df_to_image, TableStyle\n\n# Custom styling\nstyle = TableStyle(\n theme='dark',\n font_family='Arial',\n font_size=14,\n border_color='#333',\n header_bg_color='#4CAF50',\n row_bg_colors=['#f9f9f9', '#ffffff']\n)\n\ndf_to_image(\n df, \n output_path='styled_table.png',\n style=style,\n width=800,\n height=600\n)\n```\n\n## API Reference\n\n### `df_to_image(df, output_path, style=None, width=None, height=None, format='png')`\n\nConvert a pandas DataFrame to an image.\n\n**Parameters:**\n- `df` (pandas.DataFrame): The DataFrame to convert\n- `output_path` (str): Path where the image will be saved\n- `style` (TableStyle, optional): Custom styling options\n- `width` (int, optional): Image width in pixels\n- `height` (int, optional): Image height in pixels (auto if not specified)\n- `format` (str): Image format ('png', 'jpeg', 'webp')\n\n### `TableStyle`\n\nCustomization options for table appearance.\n\n**Parameters:**\n- `theme` (str): Theme name ('light', 'dark', 'minimal')\n- `font_family` (str): Font family name\n- `font_size` (int): Font size in pixels\n- `border_color` (str): Border color (CSS color)\n- `header_bg_color` (str): Header background color\n- `row_bg_colors` (list): Alternating row background colors\n\n## License\n\nMIT License\n",
"bugtrack_url": null,
"license": null,
"summary": "Convert pandas DataFrame to beautiful table images with automatic Chinese font support",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/nolanzhao/dataframe2image",
"Issues": "https://github.com/nolanzhao/dataframe2image/issues",
"Repository": "https://github.com/nolanzhao/dataframe2image"
},
"split_keywords": [
"pandas",
" dataframe",
" table",
" image",
" screenshot"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "454d18d1356e2b30dcfcd35f764de55ffec2f5860337b0b77d67976140122477",
"md5": "2e2e5455674865b57549623c64ebab8d",
"sha256": "fc4a77d0b0d284865fb04c9db926422356eb7ab2f9cc7d7fae9dedc7067ccef7"
},
"downloads": -1,
"filename": "dataframe2image-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2e2e5455674865b57549623c64ebab8d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4109733,
"upload_time": "2025-07-15T10:31:24",
"upload_time_iso_8601": "2025-07-15T10:31:24.808825Z",
"url": "https://files.pythonhosted.org/packages/45/4d/18d1356e2b30dcfcd35f764de55ffec2f5860337b0b77d67976140122477/dataframe2image-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "509f4dbe5ce02c3590c31c9b77983552f35771563ff1886716072fd9d4a49ebe",
"md5": "bc93781636da5885112a56961362784b",
"sha256": "335c3757c53f8665e223714694e0ec7363d4128ea7f0c5e40312d8c8a7228411"
},
"downloads": -1,
"filename": "dataframe2image-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "bc93781636da5885112a56961362784b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4087134,
"upload_time": "2025-07-15T10:31:28",
"upload_time_iso_8601": "2025-07-15T10:31:28.254271Z",
"url": "https://files.pythonhosted.org/packages/50/9f/4dbe5ce02c3590c31c9b77983552f35771563ff1886716072fd9d4a49ebe/dataframe2image-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 10:31:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nolanzhao",
"github_project": "dataframe2image",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pandas",
"specs": [
[
">=",
"1.3.0"
]
]
},
{
"name": "playwright",
"specs": [
[
">=",
"1.35.0"
]
]
},
{
"name": "jinja2",
"specs": [
[
">=",
"3.0.0"
]
]
},
{
"name": "pillow",
"specs": [
[
">=",
"8.0.0"
]
]
},
{
"name": "pytest",
"specs": [
[
">=",
"7.0.0"
]
]
},
{
"name": "pytest-asyncio",
"specs": [
[
">=",
"0.21.0"
]
]
},
{
"name": "black",
"specs": [
[
">=",
"22.0.0"
]
]
},
{
"name": "isort",
"specs": [
[
">=",
"5.10.0"
]
]
},
{
"name": "flake8",
"specs": [
[
">=",
"4.0.0"
]
]
},
{
"name": "mypy",
"specs": [
[
">=",
"0.991"
]
]
},
{
"name": "numpy",
"specs": [
[
">=",
"1.20.0"
]
]
}
],
"lcname": "dataframe2image"
}