Script 309: NOLS NOLM Backorder keywords

Purpose

Python script to copy input rows to output and add specific values to certain columns.

To Elaborate

This 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 purpose of this script is to manipulate the data in the input dataframe and generate an output dataframe with the desired changes.

Walking Through the Code

  1. The script defines several column constants that are used in the code.
  2. The input dataframe is copied to the output dataframe.
  3. The values from the input dataframe’s columns are assigned to the corresponding columns in the output dataframe.
  4. Specific values are added to certain columns in the output dataframe.
  5. The current date and time in the client’s timezone are stored in the variable “today”.
  6. The input dataframe is printed in a table format using the “tableize” function.

Vitals

  • Script ID : 309
  • Client ID / Customer ID: 1306917937 / 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-22 10:30
  • 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

comments powered by Disqus