Script 297: NOLS NOLM & Backorder
Purpose
Python script to update custom parameters for keywords with NOLS, NOLM or Backorder in the landing page result column.
To Elaborate
The Python script aims to update custom parameters for keywords that have NOLS, NOLM, or Backorder in the landing page result column. It performs this task by copying all input rows to the output and modifying specific columns based on predefined rules. The script also prints the input DataFrame in a tabular format.
Walking Through the Code
- The script defines several column constants, such as ‘Account’, ‘Campaign’, ‘Group’, ‘Custom Parameters’, ‘Alternative Product Required’, ‘altproducttag’, and ‘Search Bid’.
- The script initializes the output DataFrame by copying all rows from the input DataFrame.
- The script updates specific columns in the output DataFrame:
- The ‘Account’ column is set to the corresponding value from the input DataFrame.
- The ‘Campaign’ column is set to the corresponding value from the input DataFrame.
- The ‘Group’ column is set to the corresponding value from the input DataFrame.
- The ‘Search Bid’ column is set to ‘0.5’.
- The ‘altproducttag’ column is set to ‘#pdpSection_PFProdSubstit’.
- The ‘Alternative Product Required’ column is set to “true”.
- The ‘Custom Parameters’ column is set to ‘{_altproduct}=[altproducttag]’.
- The script assigns the current date to the ‘today’ variable using the ‘datetime’ module.
- The script prints the input DataFrame in a tabular format using the ‘tableize’ function.
- The script execution ends.
Vitals
- Script ID : 297
- Client ID / Customer ID: 1306917945 / 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 09:20
- 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-05-15 07:44:05 GMT