A Python package to upload pandas DataFrames to Superset for easy visualization.
Project description
Superset Accessor for Pandas DataFrames
Note: The code docs AI-generated so may not be perfect (or even right lol).
Upload your DataFrame to Superset as a datasource for rapid visualization.
Notes
- Ensure you have a database or datasource in Superset that supports CSV uploads.
- Ensure API access is enabled.
- To maintain a clean and organized Superset environment:
- Within Superset create a dedicated database or datasource (specified by the
database_nameparameter in theconfigurefunction) for this package. - Consistently use the same database or datasource name when uploading data, as the package overwrites existing data by default.
- Within Superset create a dedicated database or datasource (specified by the
- Call
SupersetAccessor.configureat least once before using theas_datasourceaccessor.
Installation
Install the package via pip:
pip install dataframe-to-superset
Usage
import pandas as pd
from dataframe_to_superset import SupersetAccessor
SupersetAccessor.configure(
base_url="https://superset",
username="your_username",
password="your_password",
provider="your_auth_provider", # e.g., "ldap" or "db"
database_name="your_database_name",
schema="your_schema_name", # optional, defaults to "public"
)
data = {"name": ["Alice", "Bob"], "age": [25, 30]}
df = pd.DataFrame(data)
url = df.superset.as_datasource("people")
print(url)
# Another example
data = {"animal": ["Wolf", "Cat"], "Sound": ["Howl", "Meow"]}
df = pd.DataFrame(data)
url = df.superset.as_datasource("animal_sounds", verbose_return = True)
print(url)
Configuration Parameters for configure Function
| Parameter | Type | Default | Description |
|---|---|---|---|
base_url |
str |
URL of Superset instance. /api/v1 is automatically appended. |
|
username |
str |
||
password |
str |
||
provider |
Literal["db", "ldap", "oauth", "oid", "remote_user"] |
Indicates the authentication provider type. | |
database_name |
str |
Name of the database/datasource in Superset where data will be uploaded. | |
schema |
str |
"public" |
Specifies the schema to upload data to (should exist on the database). |
Parameters for as_datasource Method
| Parameter | Type | Default | Description |
|---|---|---|---|
dataset_name |
str |
{username}_generated_dataset_{random_suffix} |
Name of the dataset in Superset. |
replace |
bool |
True |
Replace the existing dataset based on the dataset_name (if it already exists). |
verbose_return |
bool |
False |
Return detailed information in stead of only the url |
Return Types for as_datasource Method
| Return Type | Description | Example Response |
|---|---|---|
Dict[str, Any] (if verbose_return=True) |
Dictionary with detailed information about the created/updated dataset. | {"dataset_id": 123, "name": "animal_sounds", "url": "https://superset/explore/?dataset_id=123"} |
str (if verbose_return=False) |
URL of the uploaded dataset for direct visualisation access`. | "https://superset/explore/?dataset_id=123" |
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
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 dataframe_to_superset-0.1.5.tar.gz.
File metadata
- Download URL: dataframe_to_superset-0.1.5.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86eb604688d25159f5a3d8b455363bc9ba0d8fd87bb2debeec748b53badae965
|
|
| MD5 |
fc90673113380676a8efb9731ff86b3a
|
|
| BLAKE2b-256 |
e9e2b96c3ea6051ad3ed9c710612f4555ae78465f8d377cdb0035e6eb3691f67
|
File details
Details for the file dataframe_to_superset-0.1.5-py3-none-any.whl.
File metadata
- Download URL: dataframe_to_superset-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ce8689e3ab7c13b45111acdeae5106dc9fa7bfe78ec553c1da594476690eae1
|
|
| MD5 |
81828b054895cba9f4bed0932f2a5c76
|
|
| BLAKE2b-256 |
84782eed63feeef54a74c4b61f96e662b49968aad45f705c82423fa32f91ff05
|