Convert pandas DataFrame to beautiful table images with automatic Chinese font support
Project description
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
pip install dataframe2image
After installation, you need to install Playwright browsers:
playwright install chromium
Quick Start
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
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 convertoutput_path(str): Path where the image will be savedstyle(TableStyle, optional): Custom styling optionswidth(int, optional): Image width in pixelsheight(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 namefont_size(int): Font size in pixelsborder_color(str): Border color (CSS color)header_bg_color(str): Header background colorrow_bg_colors(list): Alternating row background colors
License
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 dataframe2image-0.2.0.tar.gz.
File metadata
- Download URL: dataframe2image-0.2.0.tar.gz
- Upload date:
- Size: 4.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
335c3757c53f8665e223714694e0ec7363d4128ea7f0c5e40312d8c8a7228411
|
|
| MD5 |
bc93781636da5885112a56961362784b
|
|
| BLAKE2b-256 |
509f4dbe5ce02c3590c31c9b77983552f35771563ff1886716072fd9d4a49ebe
|
File details
Details for the file dataframe2image-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dataframe2image-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc4a77d0b0d284865fb04c9db926422356eb7ab2f9cc7d7fae9dedc7067ccef7
|
|
| MD5 |
2e2e5455674865b57549623c64ebab8d
|
|
| BLAKE2b-256 |
454d18d1356e2b30dcfcd35f764de55ffec2f5860337b0b77d67976140122477
|