Script 205: Yesterdays Cost Dimension Tagging LEI
Purpose
The Python script transfers yesterday’s publication cost data to a new column for further processing or analysis.
To Elaborate
The script is designed to handle financial data related to advertising campaigns, specifically focusing on the cost incurred on the previous day. It takes an input DataFrame containing various columns, including the publication cost, and creates a copy of this DataFrame. The script then assigns the values from the publication cost column to a new column labeled “Yesterday’s Cost.” This operation is essential for tracking and analyzing daily expenses associated with different advertising campaigns, enabling businesses to monitor their spending and make informed budgetary decisions. The script’s functionality is crucial for maintaining accurate financial records and supporting the Structured Budget Allocation (SBA) process.
Walking Through the Code
- DataFrame Copying
- The script begins by creating a copy of the input DataFrame,
inputDf
, to ensure that the original data remains unchanged during processing. This is stored in a new DataFrame calledoutputDf
.
- The script begins by creating a copy of the input DataFrame,
- Column Assignment
- It then assigns the values from the ‘Pub. Cost $’ column of the copied DataFrame to a new column named ‘Yesterdays Cost’. This step is crucial for isolating the cost data specific to the previous day, which can be used for further analysis or reporting.
- Output Display
- Finally, the script uses a function
tableize
to print the modified DataFrame, allowing users to visually inspect the changes and verify that the data has been correctly processed.
- Finally, the script uses a function
Vitals
- Script ID : 205
- Client ID / Customer ID: 1306925259 / 45606
- Action Type: Bulk Upload
- Item Changed: Campaign
- Output Columns: Account, Campaign, Yesterdays Cost
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: Autumn Archibald (aarchibald@marinsoftware.com)
- Created by Autumn Archibald on 2023-06-16 16:09
- Last Updated by Autumn Archibald on 2023-12-06 04:01
> See it in Action
Python Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_PUB_COST = 'Pub. Cost $'
RPT_COL_YESTERDAYS_COST = 'Yesterdays Cost'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_YESTERDAYS_COST = 'Yesterdays Cost'
outputDf = inputDf.copy()
outputDf[BULK_COL_YESTERDAYS_COST] = outputDf[RPT_COL_PUB_COST]
print(tableize(outputDf))
Post generated on 2024-11-27 06:58:46 GMT