Script 197: Yesterday Cost Dimension Tagging Lumify

Purpose

The script updates a DataFrame by copying yesterday’s cost from a publication cost column.

To Elaborate

The Python script is designed to process a DataFrame by transferring data from one column to another. Specifically, it takes the values from the ‘Pub. Cost $’ column and copies them into the ‘Yesterdays Cost’ column. This operation is useful in scenarios where the cost data from the previous day needs to be tracked or reported separately. The script ensures that the ‘Yesterdays Cost’ column reflects the same values as the ‘Pub. Cost $’ column, effectively preparing the data for further analysis or reporting.

Walking Through the Code

  1. DataFrame Copying
    • The script begins by creating a copy of the input DataFrame named outputDf. This ensures that the original data remains unchanged while modifications are made to the copy.
  2. Column Data Transfer
    • The script then assigns the values from the ‘Pub. Cost $’ column of the outputDf DataFrame to the ‘Yesterdays Cost’ column. This operation effectively duplicates the cost data from the publication cost column into the yesterday’s cost column.
  3. Output Display
    • Finally, the script uses the tableize function to print the modified DataFrame, allowing users to visually verify the changes made to the data.

Vitals

  • Script ID : 197
  • Client ID / Customer ID: 716863461 / 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-15 18:11
  • 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

comments powered by Disqus