Script 201: Yesterdays Cost Dimension Tagging PreserVision
Purpose
The Python script updates a DataFrame by copying yesterday’s cost data from one column to another for structured budget allocation purposes.
To Elaborate
The Python script is designed to facilitate the process of structured budget allocation (SBA) by transferring cost data from a specified column to another within a DataFrame. This operation is crucial for maintaining accurate financial records and ensuring that budget allocations are based on the most recent cost data. The script specifically targets yesterday’s cost data, which is a common requirement in financial reporting and analysis. By automating this data transfer, the script helps streamline the process of updating financial records, reducing the potential for human error, and ensuring that budget allocations are based on up-to-date information.
Walking Through the Code
- DataFrame Copying
- The script begins by creating a copy of the input DataFrame,
inputDf
, and assigns it tooutputDf
. This ensures that the original data remains unchanged while modifications are made to the copy.
- The script begins by creating a copy of the input DataFrame,
- Column Data Transfer
- The script then transfers data from the
RPT_COL_PUB_COST
column to theBULK_COL_YESTERDAYS_COST
column within theoutputDf
. This step is crucial for updating the cost data that will be used in structured budget allocation.
- The script then transfers data from the
- Output Display
- Finally, the script uses the
tableize
function to print the updated DataFrame,outputDf
, allowing users to visually verify the changes made to the cost data.
- Finally, the script uses the
Vitals
- Script ID : 201
- Client ID / Customer ID: 94831459 / 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:02
- 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