Script 1059: SBA Transcription
Purpose
Python script to copy values from the ‘Strategy’ and ‘Strategy Target’ columns to the ‘SBA Strategy’ and ‘SBA Campaign Budget’ columns, respectively.
To Elaborate
This Python script solves the problem of copying values from specific columns in a DataFrame and pasting them into other columns. The script specifically copies values from the ‘Strategy’ column and pastes them into the ‘SBA Strategy’ column, and it also copies values from the ‘Strategy Target’ column and pastes them into the ‘SBA Campaign Budget’ column. This process allows for the allocation of budgets based on specific strategies and targets.
Walking Through the Code
- The script starts by defining the primary data source and its columns.
- It then defines the output columns and their initial values.
- The input data is copied to the output DataFrame.
- The values from the ‘Strategy’ column are copied to the ‘SBA Strategy’ column.
- The values from the ‘Strategy Target’ column are copied to the ‘SBA Campaign Budget’ column.
- The tableized version of the output DataFrame is printed.
Vitals
- Script ID : 1059
- Client ID / Customer ID: 1306927889 / 60270375
- Action Type: Bulk Upload
- Item Changed: Campaign
- Output Columns: Account, Campaign, SBA Strategy, SBA Campaign Budget
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: Grégory Pantaine (gpantaine@marinsoftware.com)
- Created by Grégory Pantaine on 2024-05-10 12:00
- Last Updated by emerryfield@marinsoftware.com on 2024-05-14 02: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
## name:
##
## description: Take Strategy and set the value in the SBA Strategy column.
## description: Take Strategy Target and set the value in the SBA Campaign Budget column.
## Copied & adjusted by Grég P.
## created: 2024-05-10
# Primary data source and columns
inputDf = dataSourceDict["1"]
# Output columns and initial values
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_STRATEGY = 'Strategy'
RPT_COL_SBA_STRATEGY = 'SBA Strategy'
RPT_COL_STRATEGY_TARGET = 'Strategy Target'
RPT_COL_SBA_CAMPAIGN_BUDGET = 'SBA Campaign Budget'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_SBA_STRATEGY = 'SBA Strategy'
BULK_COL_SBA_CAMPAIGN_BUDGET = 'SBA Campaign Budget'
# Copy input data to output
outputDf = inputDf.copy()
# Copy values from 'Strategy' column to 'SBA Strategy' column
outputDf[RPT_COL_SBA_STRATEGY] = inputDf[RPT_COL_STRATEGY]
# Copy values from 'Strategy Target' column to 'SBA Campaign Budget' column
outputDf[RPT_COL_SBA_CAMPAIGN_BUDGET] = inputDf[RPT_COL_STRATEGY_TARGET]
# Print the tableized version of the output DataFrame
print(tableize(outputDf))
Post generated on 2024-05-15 07:44:05 GMT