Pantab: Pandas DataFrames to Tableau Hyper Extracts

5.3.0 · active · verified Thu Apr 16

Pantab is a Python library that enables seamless conversion between pandas DataFrames and Tableau Hyper Extracts (.hyper files). It provides a high-performance way to get data into and out of Tableau's Hyper engine, which is used for data storage and querying within Tableau products. The current version is 5.3.0, and it generally follows a release cadence with minor versions every few months, often including bug fixes and Python version support updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a pandas DataFrame, write it to a Tableau Hyper file using `pantab.to_hyper`, and then read it back into a DataFrame using `pantab.frame_from_hyper`. It includes cleanup to remove the generated Hyper file.

import pandas as pd
import pantab as pt
import os

data = {
    'col1': [1, 2, 3],
    'col2': ['A', 'B', 'C'],
    'col3': [True, False, True]
}
df = pd.DataFrame(data)

hyper_file = 'my_data.hyper'
table_name = 'MyTable'

try:
    # Write DataFrame to Hyper file
    pt.to_hyper(df, hyper_file, table=table_name)
    print(f"DataFrame written to {hyper_file} successfully.")

    # Read DataFrame from Hyper file
    read_df = pt.frame_from_hyper(hyper_file, table=table_name)
    print(f"DataFrame read from {hyper_file} successfully:")
    print(read_df)

finally:
    # Clean up the generated file
    if os.path.exists(hyper_file):
        os.remove(hyper_file)
        print(f"Cleaned up {hyper_file}.")

view raw JSON →