Script 331: Conversion Influencers Clear
Purpose
The Python script is designed to clear the “Conversion Influencers” dimension values in a dataset.
To Elaborate
The script addresses the need to reset or clear specific dimension values, specifically the “Conversion Influencers” field, within a dataset. This is likely part of a larger data processing workflow where maintaining only a limited number of labeled keywords is necessary for subsequent operations. By clearing these values, the script ensures that the dataset is prepared for the next day’s processing, which will reassign or update these dimension values as needed. This process is crucial for maintaining data accuracy and relevance in reporting or analysis tasks, particularly in environments where data changes frequently and needs to be kept up-to-date.
Walking Through the Code
- Initialization of Constants
- The script begins by defining several constants that represent column names used in the dataset. These constants are used to ensure consistency and avoid hardcoding column names throughout the script.
- Copying the Input DataFrame
- The script creates a copy of the input DataFrame (
inputDf
) tooutputDf
. This is done to preserve the original data while making modifications to the copy.
- The script creates a copy of the input DataFrame (
- Clearing Dimension Values
- The script sets the “Conversion Influencers” column in the
outputDf
to an empty string. This effectively clears any existing values in this column, preparing it for future updates.
- The script sets the “Conversion Influencers” column in the
- Output
- The modified DataFrame (
outputDf
) is printed, showing the cleared “Conversion Influencers” column. This step is crucial for verifying that the clearing operation was successful.
- The modified DataFrame (
Vitals
- Script ID : 331
- Client ID / Customer ID: 1306926109 / 60269815
- Action Type: Bulk Upload
- Item Changed: Keyword
- Output Columns: Account, Campaign, Group, Keyword, Match Type, Conversion Influencers
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: Byron Porter (bporter@marinsoftware.com)
- Created by Byron Porter on 2023-10-04 23:27
- Last Updated by Byron Porter 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
RPT_COL_KEYWORD = 'Keyword'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP = 'Group'
RPT_COL_MATCH_TYPE = 'Match Type'
RPT_COL_CONVERSION_INFLUENCERS = 'Conversion Influencers'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_KEYWORD = 'Keyword'
BULK_COL_MATCH_TYPE = 'Match Type'
BULK_COL_CONVERSION_INFLUENCERS = 'Conversion Influencers'
# Assign current date to a parameter
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
# blank out existing dimension values so that there are only 10 keywords labeled once the next day's dimension script runs
outputDf = inputDf.copy()
outputDf[BULK_COL_CONVERSION_INFLUENCERS] = ""
print("outputDf", tableize(outputDf))
Post generated on 2024-11-27 06:58:46 GMT