Script 1131: Clear Automation Outlier

Purpose

The Python script is designed to clear the ‘AUTOMATION - Outlier’ column in a data table to prepare it for further processing.

To Elaborate

The script addresses the need to reset or clear the ‘AUTOMATION - Outlier’ column in a dataset, which is likely used for tracking or flagging outliers in an automated process. By clearing this column, the script ensures that any previous outlier flags are removed, allowing for a fresh analysis or data processing cycle. This is particularly useful in scenarios where data is periodically updated or reviewed, and previous outlier indicators may no longer be relevant. The script operates on a copy of the original dataset to preserve the integrity of the initial data, ensuring that any changes made do not affect the original data source.

Walking Through the Code

  1. Data Preparation
    • The script begins by defining the primary data source and relevant column names, which are used to identify and manipulate specific parts of the dataset.
    • A copy of the input DataFrame (inputDf) is created and assigned to outputDf to ensure that the original data remains unchanged during processing.
  2. Clearing the Outlier Column
    • The script specifically targets the ‘AUTOMATION - Outlier’ column in the outputDf DataFrame, setting its values to an empty string. This effectively clears any existing data in this column, resetting it for future use.
  3. Output Verification
    • The script concludes by printing the first few rows of the modified DataFrame using the tableize function, allowing users to verify that the ‘AUTOMATION - Outlier’ column has been successfully cleared.

Vitals

  • Script ID : 1131
  • Client ID / Customer ID: 1306927029 / 60270153
  • Action Type: Bulk Upload
  • Item Changed: AdGroup
  • Output Columns: Account, Campaign, Group, AUTOMATION - Outlier
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: dwaidhas@marinsoftware.com (dwaidhas@marinsoftware.com)
  • Created by dwaidhas@marinsoftware.com on 2024-05-22 18:26
  • Last Updated by dwaidhas@marinsoftware.com on 2024-05-22 18:26
> 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
33
##
## name: Clear Automation - Outlier
## description:
##  
## 
## author: Dana Waidhas 
## created: 2024-05-22
## 

today = datetime.datetime.now(CLIENT_TIMEZONE).date()

# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_GROUP = 'Group'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP_ID = 'Group ID'
RPT_COL_AUTOMATION__OUTLIER = 'AUTOMATION - Outlier'

# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_AUTOMATION__OUTLIER = 'AUTOMATION - Outlier'
outputDf[BULK_COL_AUTOMATION__OUTLIER] = "<<YOUR VALUE>>"

# user code start here
outputDf = inputDf.copy()  # Make a copy to avoid modifying the original DataFrame
outputDf[BULK_COL_AUTOMATION__OUTLIER] = ""  # Clear the 'AUTOMATION INFO' column

# user code start here
print(tableize(outputDf.head()))

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

comments powered by Disqus