fivetran#

Fivetran data processing functions.

These functions help transform Fivetran’s standardized schemas into formats suitable for PyMC-Marketing models.

Example usage for MMM:

from pymc_marketing.data.fivetran import (
    process_fivetran_ad_reporting,
    process_fivetran_shopify_unique_orders,
)
from pymc_marketing.mmm import MMM

# Process ad spend data for media channels
x = process_fivetran_ad_reporting(
    campaign_df, value_columns="spend", rename_date_to="date"
)
# Result: date | facebook_ads_spend | google_ads_spend | ...

# Process conversion data (orders) as target variable
y = process_fivetran_shopify_unique_orders(orders_df)
# Result: date | orders

# Use in MMM model
mmm = MMM(...)
mmm.fit(X=x, y=y["orders"])

There are also pandas accessors for these functions which allows calling them from a pandas DataFrame. These accessors are registered under the fivetran namespace and can be accessed after importing pymc_marketing.

import pandas as pd

from pymc_marketing.mmm import MMM


campaign_df: pd.DataFrame = ...
orders_df: pd.DataFrame = ...

X: pd.DataFrame = campaign_df.fivetran.process_ad_reporting(value_columns="spend")
y: pd.DataFrame = orders_df.fivetran.process_shopify_unique_orders()

# Use in MMM model
mmm = MMM(...)
mmm.fit(X=x, y=y["orders"])

Functions

process_fivetran_ad_reporting(df[, ...])

Process Fivetran Ad Reporting tables into wide, model-ready features.

process_fivetran_shopify_unique_orders(df, *)

Compute daily unique order counts from a (pre-filtered) Shopify dataset.

Classes

FivetranAccessor(obj)

Accessor for Fivetran data processing functions.