Script 303: NOLS NOLM & Backorder

Purpose

The Python script processes input data to update specific columns with predefined values for structured budget allocation (SBA) purposes.

To Elaborate

The Python script is designed to process a dataset by updating specific columns with predefined values. This is particularly useful in scenarios where structured budget allocation (SBA) is required, such as in advertising campaigns or inventory management. The script takes an input DataFrame and modifies certain columns to ensure that the data aligns with the desired business rules. These rules include setting a fixed search bid, marking alternative products as required, and updating custom parameters with specific tags. The script ensures that the output data is consistent and ready for further processing or analysis, adhering to the structured budget allocation requirements.

Walking Through the Code

  1. Initialization and Setup
    • The script begins by defining constants for column names that will be used to access and modify the DataFrame. These constants represent the key fields in the dataset that are relevant to the structured budget allocation process.
  2. Data Processing
    • The script copies specific columns from the input DataFrame to the output DataFrame. This ensures that the essential data is retained while allowing for modifications.
    • It sets the ‘Search Bid’ column to a fixed value of ‘0.5’, which is a user-changeable parameter that can be adjusted based on business needs.
    • The ‘Alternative Product Required’ column is set to “true”, indicating that alternative products should be considered in the allocation process.
    • The ‘Custom Parameters’ column is updated with a specific tag, ensuring that the data is tagged appropriately for further processing.
  3. Output Preparation
    • The script prepares the output DataFrame with the updated values, ready for further analysis or integration into other systems.

Vitals

  • Script ID : 303
  • Client ID / Customer ID: 1306917939 / 64302
  • Action Type: Bulk Upload
  • Item Changed: AdGroup
  • Output Columns: Account, Campaign, Group, Custom Parameters, Alternative Product Required, altproducttag
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Tom McCaughey (tmccaughey@marinsoftware.com)
  • Created by Tom McCaughey on 2023-09-15 11:07
  • Last Updated by Tom McCaughey 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
15
16
17
18
19
20
21
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_CUSTOM_PARAMETERS = 'Custom Parameters'
BULK_COL_ALTERNATIVE_PRODUCTREQUIRED = 'Alternative Product Required'
BULK_COL_ALTPRODUCTTAG = 'altproducttag'
BULk_COL_SEARCH_BID = 'Search Bid'

# copy all input rows to output
#outputDf = inputDf.copy()
outputDf[BULK_COL_ACCOUNT] = inputDf[BULK_COL_ACCOUNT]
outputDf[BULK_COL_CAMPAIGN] = inputDf[BULK_COL_CAMPAIGN]
outputDf[BULK_COL_GROUP] = inputDf[BULK_COL_GROUP]
outputDf[BULk_COL_SEARCH_BID] = '0.5'
outputDf[BULK_COL_ALTPRODUCTTAG] = '#pdpSection_PFProdSubstit'
outputDf[BULK_COL_ALTERNATIVE_PRODUCTREQUIRED] = "true"
outputDf[BULK_COL_CUSTOM_PARAMETERS] = '{_altproduct}=[altproducttag]'

today = datetime.datetime.now(CLIENT_TIMEZONE).date()
print(tableize(inputDf))

Post generated on 2024-11-27 06:58:46 GMT

comments powered by Disqus