Skip to main content

A Python package to upload pandas DataFrames to Superset for easy visualization.

Project description

DataFrame to Superset

A Python package to upload pandas DataFrames to Superset. The goal is to visualize your DataFrame inside Superset by providing an easy way to access your data in Superset.

You need a database/datasource in Superset which allows you to upload CSV files. It is recommended to create a separate database/datasource for this purpose and to always keep the name the same when uploading because it overwrites by default. This will help combat clutter created by this package.

Installation

You can install the package using pip:

pip install dataframe-to-superset

Usage

There are three ways to upload a pandas DataFrame to Superset:

1. Creating an object of DataFrameToSuperset

from dataframe_to_superset import DataFrameToSuperset
import pandas as pd

# Create a DataFrameToSuperset object
uploader = DataFrameToSuperset(
    base_url="http://your-superset-instance",
    username="your-username",
    password="your-password",
    provider="db",  # or "ldap"
    database_name="your-database-name",
    schema="public"  # optional, defaults to "public"
)

# Create a pandas DataFrame
df = pd.DataFrame({
    "name": ["Alice", "Bob", "Charlie"],
    "age": [25, 30, 35],
    "join_date": pd.to_datetime(["2021-01-01", "2021-06-15", "2021-09-30"])
})

# Upload the DataFrame
accessable_url = uploader.to_superset(df, name="employees_dataset")
print(accessable_url)

2. Using upload_dataframe_to_superset

from dataframe_to_superset import upload_dataframe_to_superset
import pandas as pd

# Create a pandas DataFrame
df = pd.DataFrame({
    "name": ["Alice", "Bob", "Charlie"],
    "age": [25, 30, 35],
    "join_date": pd.to_datetime(["2021-01-01", "2021-06-15", "2021-09-30"])
})

# Upload the DataFrame
accessable_url = upload_dataframe_to_superset(
    dataframe=df,
    base_url="http://your-superset-instance",
    username="your-username",
    password="your-password",
    provider="db",  # or "ldap"
    database_name="your-database-name",
    schema="public",  # optional, defaults to "public"
    name="employees_dataset"  # optional, defaults to a generated name
)
print(accessable_url)

3. Applying the monkey patch

from dataframe_to_superset import monkey_patch_to_allow_df_to_superset
import pandas as pd

# Apply the monkey patch
monkey_patch_to_allow_df_to_superset(
    base_url="http://your-superset-instance",
    username="your-username",
    password="your-password",
    provider="db",  # or "ldap"
    database_name="your-database-name",
    schema="public",  # optional, defaults to "public"
)

# Create a pandas DataFrame
df = pd.DataFrame({
    "name": ["Alice", "Bob", "Charlie"],
    "age": [25, 30, 35],
    "join_date": pd.to_datetime(["2021-01-01", "2021-06-15", "2021-09-30"])
})

df.name = 'people'

# Upload the DataFrame using the new method
accessable_url = df.to_superset()
print(accessable_url)

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

dataframe_to_superset-0.1.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

dataframe_to_superset-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file dataframe_to_superset-0.1.1.tar.gz.

File metadata

File hashes

Hashes for dataframe_to_superset-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7eae75f78a98da8fa56a86d17978a69c1607f1ed9329e3850ccace69a69ab6a2
MD5 e7f4aa7efca39cfc452e95757d1eef91
BLAKE2b-256 b2013344f3d9cef5acea8159d79e567e8143e3f2ec0c3fafaf6b08a3c23a3b10

See more details on using hashes here.

File details

Details for the file dataframe_to_superset-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dataframe_to_superset-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 260c0a15b8b8869705e38bb33f6a065c3027bb8b0eb08d0f6f8b1b21c507967f
MD5 3daa181adda691161949c544d4b6f9fa
BLAKE2b-256 ad7ac0c354fc568ca8c567c101b38648d6fbaab9efb746dd9695a008ef561ec7

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