Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PowerBI & Tableau Export

New in 2.4.34 Export

Export predictions and feature matrices directly to PowerBI Push dataset JSON or Tableau TDS/CSV — native format, no extra tooling. / Export les prédictions et matrices de features en JSON PowerBI ou TDS/CSV Tableau.

✓ PowerBI JSON ✓ Tableau TDS + CSV
PowerBI format Push dataset API compatible
Tableau format TDS + CSV data source + extract
Columns X + y + ŷ feature, target, pred
📊
export_powerbi

Returns a JSON string representing a PowerBI Push dataset. Paste into the PowerBI REST API or save to .json.

📋
export_tableau_tds

Returns a Tableau Data Source XML (.tds). Defines all columns — open in Tableau Desktop to connect instantly.

📁
export_tableau_csv

Returns a CSV string with a header row. Includes feature columns, optional target and optional predictions.

🔗
Combine with Registry

Export predictions from a registry-loaded model payload and share reproducible exports alongside versioned models.

Quick start
import seraplot as sp, numpy as np

X = np.random.randn(200, 3)
y = X[:, 0] * 2 + np.random.randn(200) * 0.1

model = sp.LinearRegression()
model.fit(X, y)
yhat = model.predict(X)

pbi_json = sp.export_powerbi(
    name   = "HousePrice",
    table  = "Predictions",
    X      = X,
    y      = list(y),
    y_pred = list(yhat),
)
with open("powerbi_dataset.json", "w") as f:
    f.write(pbi_json)

tds_xml = sp.export_tableau_tds(
    name   = "HousePrice",
    X      = X,
    y      = list(y),
    y_pred = list(yhat),
)
with open("house_price.tds", "w") as f:
    f.write(tds_xml)

csv_str = sp.export_tableau_csv(
    name   = "HousePrice",
    X      = X,
    y      = list(y),
    y_pred = list(yhat),
)
with open("house_price.csv", "w") as f:
    f.write(csv_str)

API Reference

export_powerbi
ParameterTypeDefaultDescription
namestrDataset name (appears in PowerBI)
tablestrTable name inside the dataset
Xlist[list[float]]Feature matrix, shape (n, p)
ylist[float] | NoneNoneTarget values (optional)
y_predlist[float] | NoneNonePredicted values (optional)
Returns → str — PowerBI Push dataset JSON
export_tableau_tds
ParameterTypeDefaultDescription
namestrData source name in Tableau
Xlist[list[float]]Feature matrix
ylist[float] | NoneNoneTarget values (optional)
y_predlist[float] | NoneNonePredicted values (optional)
Returns → str — Tableau TDS XML
export_tableau_csv
ParameterTypeDefaultDescription
namestrUsed as comment in header row
Xlist[list[float]]Feature matrix
ylist[float] | NoneNoneTarget values (optional)
y_predlist[float] | NoneNonePredicted values (optional)
Returns → str — CSV with header row (feat_0, feat_1, …, target, prediction)
ℹ️
Column names are auto-generated: feat_0feat_{p-1}, target, prediction. All functions return strings — write them to disk or POST them to the relevant API.

Référence API

export_powerbi
ParamètreTypeDéfautDescription
namestrNom du dataset (visible dans PowerBI)
tablestrNom de la table dans le dataset
Xlist[list[float]]Matrice de features, forme (n, p)
ylist[float] | NoneNoneValeurs cibles (optionnel)
y_predlist[float] | NoneNonePrédictions (optionnel)
Retourne → str — JSON Push dataset PowerBI
export_tableau_tds
ParamètreTypeDéfautDescription
namestrNom de la source de données dans Tableau
Xlist[list[float]]Matrice de features
ylist[float] | NoneNoneValeurs cibles (optionnel)
y_predlist[float] | NoneNonePrédictions (optionnel)
Retourne → str — XML Tableau TDS
export_tableau_csv
ParamètreTypeDéfautDescription
namestrUtilisé en commentaire dans la ligne d'en-tête
Xlist[list[float]]Matrice de features
ylist[float] | NoneNoneValeurs cibles (optionnel)
y_predlist[float] | NoneNonePrédictions (optionnel)
Retourne → str — CSV avec en-tête (feat_0, feat_1, …, target, prediction)
💡
Les colonnes sont nommées automatiquement : feat_0feat_{p-1}, target, prediction. Toutes les fonctions retournent des chaînes de caractères — écrivez-les sur disque ou envoyez-les à l'API concernée via HTTP POST.