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.2.tar.gz (15.5 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.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for dataframe_to_superset-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7fff760dc9c8d832b194f45b1a9b7813985d859e33057e556bb9b247a566e01d
MD5 38d1ffd77e384e769767fe0efcbe8cd9
BLAKE2b-256 ca9a2ede655f6588620a6cb6bcf2d0cad66094fbca7bd00cc835bd660f9b8bce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dataframe_to_superset-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 47332376434fa11dfa5d65140f92def4b2a21c25627220e656e77c6dad81086b
MD5 b0993442201fb00eb3d4517e6b39ff39
BLAKE2b-256 bdae5db37830626930e8de1081764754cfcdb8611e443c86508c8b2ff5b88e16

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