Script 1163: Match DA and SBA Targets
Purpose
The Python script aligns the SBA Strategy Name and Targets with those of the Dynamic Allocation Strategy.
To Elaborate
The script is designed to synchronize the strategy names and targets between two financial planning frameworks: Structured Budget Allocation (SBA) and Dynamic Allocation (DA). It ensures that the strategy names and their corresponding targets in the SBA framework match those in the DA framework. This alignment is crucial for maintaining consistency in budget planning and execution. The script achieves this by transferring relevant data from a primary data source to an output structure, effectively updating the SBA strategy and campaign budget fields with the corresponding values from the DA framework.
Walking Through the Code
- Data Initialization
- The script begins by defining the primary data source,
inputDf
, which contains the necessary columns for processing. - Key columns from the data source are identified, such as ‘Campaign’, ‘Account’, ‘Strategy’, and ‘Strategy Target’.
- The script begins by defining the primary data source,
- Data Transfer
- The script transfers values from the input data frame to the output data frame.
- Specifically, it maps the ‘Strategy’ column from the input to the ‘SBA Strategy’ column in the output, and the ‘Strategy Target’ to the ‘SBA Campaign Budget’.
- Output Verification
- The script prints the first few rows of both the input and output data frames to verify the data transfer process.
- This step ensures that the SBA strategy and budget fields are correctly updated with the DA strategy and target values.
Vitals
- Script ID : 1163
- Client ID / Customer ID: 1306926629 / 60270083
- Action Type: Bulk Upload
- Item Changed: Campaign
- Output Columns: Account, Campaign, SBA Strategy, SBA Campaign Budget
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: dwaidhas@marinsoftware.com (dwaidhas@marinsoftware.com)
- Created by dwaidhas@marinsoftware.com on 2024-05-29 20:44
- Last Updated by dwaidhas@marinsoftware.com on 2024-05-29 20:45
> 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
31
32
33
34
35
36
37
##
## name: Match DA and SBA Targets
## description:
## Matches the SBA Strategy Name and Targets to the Dynamic Allocation ones. The Dynamic Allocation Strategy + Target get's updated by the 'Update Strategy Spend Target via Master Sheet' Script.
##
## author:
## created: 2024-05-29
##
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_STRATEGY = 'Strategy'
RPT_COL_STRATEGY_TARGET = 'Strategy Target'
RPT_COL_SBA_STRATEGY = 'SBA Strategy'
RPT_COL_SBA_CAMPAIGN_BUDGET = 'SBA Campaign Budget'
# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_SBA_STRATEGY = 'SBA Strategy'
BULK_COL_SBA_CAMPAIGN_BUDGET = 'SBA Campaign Budget'
# user code starts here
print(tableize(inputDf.head()))
# Transfer values from input columns to output columns
outputDf[BULK_COL_SBA_STRATEGY] = inputDf[RPT_COL_STRATEGY]
outputDf[BULK_COL_SBA_CAMPAIGN_BUDGET] = inputDf[RPT_COL_STRATEGY_TARGET]
# Display the first few rows of the output dataframe
print(tableize(outputDf.head()))
Post generated on 2024-11-27 06:58:46 GMT