Script 1633: Always Push Budgets
Purpose:
The Python script automates the process of updating daily budget allocations for advertising campaigns based on recommended values.
To Elaborate
The script is designed to streamline the process of updating daily budgets for advertising campaigns by utilizing recommended budget values. It takes input data from a primary data source, which includes various campaign-related metrics and recommendations. The script processes this data to create an output DataFrame that contains updated daily budget allocations for each campaign. This ensures that the campaigns are aligned with the latest budget recommendations, potentially optimizing their performance. The script is particularly useful for marketing teams who need to regularly adjust campaign budgets based on performance data and strategic recommendations.
Walking Through the Code
- Data Initialization:
- The script begins by defining the primary data source and specifying the relevant columns from the input data. This includes campaign details and various performance metrics.
- Output DataFrame Setup:
- An output DataFrame is initialized with specific columns for account, campaign, campaign ID, and daily budget. The daily budget column is initially set to a placeholder value.
- Data Processing:
- The script populates the output DataFrame with data from the input DataFrame, specifically copying over the account, campaign, and campaign ID columns. The daily budget column is updated with the recommended daily budget values from the input data.
- Output Display:
- The script prints the first few rows of both the input and output DataFrames to provide a quick view of the data transformation process. This helps in verifying that the budget updates have been correctly applied.
Vitals
- Script ID : 1633
- Client ID / Customer ID: 1306927943 / 60270393
- Action Type: Bulk Upload
- Item Changed: Campaign
- Output Columns: Account, Campaign, Daily Budget, Campaign ID
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: dwaidhas@marinsoftware.com (dwaidhas@marinsoftware.com)
- Created by dwaidhas@marinsoftware.com on 2025-01-17 16:55
- Last Updated by dwaidhas@marinsoftware.com on 2025-01-17 16:57
> 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
##
## name: Always Push Budgets
## description:
##
##
## author:
## created: 2025-01-17
##
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_CAMPAIGN_TYPE = 'Campaign Type'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_STRATEGY = 'Strategy'
RPT_COL_STRATEGY_TARGET = 'Strategy Target'
RPT_COL_IMPR = 'Impr.'
RPT_COL_CLICKS = 'Clicks'
RPT_COL_PUB_COST = 'Pub. Cost $'
RPT_COL_CTR = 'CTR %'
RPT_COL_CONV = 'Conv.'
RPT_COL_COST_PER_CONV = 'Cost/Conv. $'
RPT_COL_IMPR_SHARE = 'Impr. share %'
RPT_COL_LOST_IMPR_SHARE_BUDGET = 'Lost Impr. Share (Budget) %'
RPT_COL_LOST_IMPR_SHARE_RANK = 'Lost Impr. Share (Rank) %'
RPT_COL_SHARED_BUDGET = 'Shared Budget'
RPT_COL_PUBLISHER_BID_PORTFOLIO_NAME = 'Publisher Bid Portfolio Name'
RPT_COL_PUBLISHER_BID_STRATEGY = 'Publisher Bid Strategy'
RPT_COL_PUBLISHER_TARGET_CPA = 'Publisher Target CPA'
RPT_COL_PUBLISHER_TARGET_ROAS = 'Publisher Target ROAS'
RPT_COL_UNCONSTRAINED_RECOMMENDED_CPA_PER_ROAS_TARGET = 'Unconstrained Recommended CPA/ROAS Target'
RPT_COL_RECOMMENDED_CPA_PER_ROAS_TARGET = 'Recommended CPA/ROAS Target'
RPT_COL_DAILY_BUDGET = 'Daily Budget'
RPT_COL_UNCONSTRAINED_RECOMMENDED_DAILY_BUDGET = 'Unconstrained Recommended Daily Budget'
RPT_COL_RECOMMENDED_DAILY_BUDGET = 'Recommended Daily Budget'
RPT_COL_RECOMMENDATION_CONSTRAINTS = 'Recommendation Constraints'
RPT_COL_CAMPAIGN_ID = 'Campaign ID'
RPT_COL_DAILY_BUDGET_RECOMMENDATION_DATE = 'Daily Budget Recommendation Date'
RPT_COL_CPA_PER_ROAS_TARGET_RECOMMENDATION_DATE = 'CPA/ROAS Target Recommendation Date'
RPT_COL_PUBLISHER_BID_STRATEGY_SYSTEM_STATUS = 'Publisher Bid Strategy System Status'
RPT_COL_AUTO_PAUSE_DATE = 'Auto Pause Date'
RPT_COL_AUTO_PAUSE_REC_CAMPAIGN_STATUS = 'Auto Pause Rec. Campaign Status'
RPT_COL_AUTO_PAUSE_STATUS = 'Auto Pause Status'
RPT_COL_CAMPAIGN_OVERRIDE = 'Campaign Override'
# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_DAILY_BUDGET = 'Daily Budget'
BULK_COL_CAMPAIGN_ID = 'Campaign ID'
outputDf[BULK_COL_DAILY_BUDGET] = "<<YOUR VALUE>>"
outputDf[BULK_COL_CAMPAIGN_ID] = "<<YOUR VALUE>>"
# user code start here
print(tableize(inputDf.head()))
# Create the output DataFrame
outputDf = pd.DataFrame()
outputDf[BULK_COL_ACCOUNT] = inputDf['Account']
outputDf[BULK_COL_CAMPAIGN] = inputDf['Campaign']
outputDf[BULK_COL_CAMPAIGN_ID] = inputDf['Campaign ID']
outputDf[BULK_COL_DAILY_BUDGET] = inputDf[RPT_COL_RECOMMENDED_DAILY_BUDGET]
# Print the first few rows of the output DataFrame
print(outputDf.head())
print(tableize(inputDf.head()))
Post generated on 2025-03-11 01:25:51 GMT