Script 299: NOLS NOLM & Backorder
Purpose
Python script to copy input rows to output and add specific values to certain columns.
To Elaborate
The Python script takes an input dataframe and copies all the rows to an output dataframe. It then adds specific values to certain columns in the output dataframe. The script also prints the input dataframe in a tabular format.
Walking Through the Code
- The script defines several column constants.
- The input dataframe is copied to the output dataframe.
- The values from the input dataframe’s columns are assigned to the corresponding columns in the output dataframe.
- Specific values are added to the columns BULk_COL_SEARCH_BID, BULK_COL_ALTPRODUCTTAG, BULK_COL_ALTERNATIVE_PRODUCTREQUIRED, and BULK_COL_CUSTOM_PARAMETERS in the output dataframe.
- The current date and time in the client’s timezone is stored in the variable today.
- The input dataframe is printed in a tabular format using the tableize function.
Vitals
- Script ID : 299
- Client ID / Customer ID: 1306917931 / 64302
- Action Type: Bulk Upload
- Item Changed: AdGroup
- Output Columns: Account, Campaign, Group, Custom Parameters, altproducttag, Alternative Product Required
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: Tom McCaughey (tmccaughey@marinsoftware.com)
- Created by Tom McCaughey on 2023-09-15 09:52
- 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