Script 1745: Script Example Dimension Tagging

Purpose:

The script processes and tags dimensions in a dataset related to campaigns, publishers, and accounts.

To Elaborate

The Python script is designed to process a dataset containing information about various campaigns, publishers, and accounts. It aims to tag specific dimensions within this dataset, such as campaign status and type, and prepare it for further analysis or reporting. The script utilizes a primary data source to extract relevant columns and initializes output columns with default values. The primary focus is on organizing and structuring the data to facilitate easier analysis and reporting, particularly in the context of marketing or advertising campaigns.

Walking Through the Code

  1. Initialization:
    • The script begins by defining the primary data source, inputDf, which contains the dataset to be processed.
    • Several column names are defined, which are used to identify specific data points within the dataset, such as campaign, publisher, account, and product example.
  2. Output Preparation:
    • The script initializes output columns with default values, setting up the structure for the processed data.
    • The outputDf is prepared with initial values for columns like ‘Account’, ‘Campaign’, and ‘Product Example’, which are crucial for the tagging process.
  3. Data Display:
    • The script includes a print statement to display the first few rows of the input dataset, providing a quick overview of the data being processed.

Vitals

  • Script ID : 1745
  • Client ID / Customer ID: 1306928827 / 60270653
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Campaign
  • Output Columns: Account, Campaign, Product Example
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Grégory Pantaine (gpantaine@marinsoftware.com)
  • Created by Grégory Pantaine on 2025-02-11 12:54
  • Last Updated by Grégory Pantaine on 2025-02-11 12:59
> See it in Action

Python Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##
## name: Script - Example - Dimension Tagging
## description:
##  
## 
## author: 
## created: 2025-02-11
## 

today = datetime.datetime.now(CLIENT_TIMEZONE).date()

# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_PRODUCT_EXAMPLE = 'Product Example'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_CAMPAIGN_TYPE = 'Campaign Type'
RPT_COL_CLICKS = 'Clicks'

# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_PRODUCT_EXAMPLE = 'Product Example'
outputDf[BULK_COL_PRODUCT_EXAMPLE] = 'Project Name'

# user code start here
print(tableize(inputDf.head()))

Post generated on 2025-03-11 01:25:51 GMT

comments powered by Disqus