Skip to main content

Convert pandas DataFrame to beautiful table images

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 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

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

dataframe2image-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

dataframe2image-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file dataframe2image-0.1.0.tar.gz.

File metadata

  • Download URL: dataframe2image-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for dataframe2image-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5d5daffc3fa8af55c4e5afabc4f9216c0d48c325711d412b0aef12bcfe7e967
MD5 ffa8fc0726519073bc19ba5627d14374
BLAKE2b-256 f8e8fe11d81783b4adc2829c951497a4bfb3eef3a2eef2876c7e70ec06d78bc9

See more details on using hashes here.

File details

Details for the file dataframe2image-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dataframe2image-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c46f422ba4681a6609caef2f8c2147b1bbc021f2e9595c4084905503eed2de70
MD5 3601d23e4d177dce757f0ec02d59df72
BLAKE2b-256 b805f25cb02d36432ef17251fa250cebd9aece419d5c967bf28869b02ccf4139

See more details on using hashes here.

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