Script 453: Automate ProductGroup SetBidOverride

Purpose

The script automates the process of setting all active Google Product Groups to Bid Override with no end date.

To Elaborate

The Python script is designed to automate the task of updating Google Product Groups by setting their bid status to “Bid Override” without specifying an end date. This is particularly useful for managing large-scale advertising campaigns where manual updates would be time-consuming and prone to error. The script identifies product groups that currently have their bid override status set to “Off” and changes it to “On,” ensuring that all active product groups are consistently managed. This process helps in maintaining the effectiveness of advertising strategies by ensuring that bid overrides are applied uniformly across all relevant product groups.

Walking Through the Code

  1. Initial Setup and Constants
    The script begins by defining several constants that represent column names used in the input and output data frames. These constants are used to ensure consistency when accessing and modifying data within the script.

  2. Identifying Product Groups with ‘Off’ Bid Override
    The script checks the RPT_COL_OVERRIDE column in the input DataFrame to identify rows where the bid override status is “Off.” This is done using a boolean mask that filters the DataFrame based on the presence of the word “Off.”

  3. Creating a DataFrame for Bid Override Changes
    A new DataFrame, overrideoffDf, is created to store the filtered data. This DataFrame includes only the columns necessary for the bid override update: account, campaign, group, product group ID, and bid override status. The script then sets the bid override status to “On” for all entries in this DataFrame.

  4. Merging and Output
    The overrideoffDf DataFrame is assigned to outputDf, which represents the final output of the script. The script concludes by printing a tableized version of outputDf, providing a clear view of the changes made to the bid override statuses.

Vitals

  • Script ID : 453
  • Client ID / Customer ID: 1306912103 / 60267913
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Product Group
  • Output Columns: Account, Campaign, Group, Product Group ID, Bid Override
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Grégory Pantaine (gpantaine@marinsoftware.com)
  • Created by Grégory Pantaine on 2023-10-30 10:29
  • Last Updated by Grégory Pantaine 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
22
23
24
25
26
27
28
29
30
31
32
# Author: Gregory Pantaine
# Created: 2023-10-27
# Description: set all active Google Product Groups to Bid Override with no end date.
# Scripts name: Automate-ProductGroup-SetBidOverride
# Report name (M1):


RPT_COL_CAMPAIGN = 'Group'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_OVERRIDE = 'Bid Override'
RPT_COL_PGID = 'Product Group ID'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_BID_OVER = 'Bid Override'
BULK_COL_GROUP = 'Group'
BULK_COL_PGID = 'Product Group ID'


# Check if RPT_COL_OVERRIDE column has 'Off'
bcheck = (inputDf[RPT_COL_OVERRIDE].str.contains('Off', case=True, na=False))

# Use check to create one DataFrame for Off, to change to on.
overrideoffDf = inputDf.loc[bcheck, [BULK_COL_ACCOUNT, BULK_COL_CAMPAIGN, BULK_COL_GROUP, BULK_COL_PGID, BULK_COL_BID_OVER]]
overrideoffDf.loc[:, BULK_COL_BID_OVER] = 'On'

# Merges the Brand and Non-Brand dataframes
outputDf = overrideoffDf

# Print the tableized version of the output DataFrame
print(tableize(outputDf))

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

comments powered by Disqus