Script 311: NOLS

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

  1. The script defines several column constants for the input and output DataFrames.
  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 the columns BULk_COL_SEARCH_BID, BULK_COL_ALTPRODUCTTAG, BULK_COL_ALTERNATIVE_PRODUCTREQUIRED, and BULK_COL_CUSTOM_PARAMETERS in the output DataFrame.
  5. The current date and time in the client’s timezone is stored in the variable today.
  6. The input DataFrame is printed in a tabular format using the tableize function.

Vitals

  • Script ID : 311
  • Client ID / Customer ID: 1306917933 / 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:56
  • 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