Script 1125: Clear Automation Outlier

Purpose

The Python script processes a data source to clear and prepare a specific column for further automation tasks related to outlier detection.

To Elaborate

The script is designed to handle data preparation tasks for a process referred to as “Clear Automation - Outlier.” It focuses on managing a DataFrame, which is a structured data format commonly used in Python for data manipulation. The script’s primary function is to clear the contents of a specific column labeled ‘AUTOMATION - Outlier’ in the DataFrame. This preparation step is crucial for subsequent automation processes that may involve detecting or handling outliers in the data. By ensuring that the column is empty, the script sets the stage for accurate and efficient data processing in later stages of the workflow.

Walking Through the Code

  1. Data Initialization
    • The script begins by defining the primary data source, inputDf, which is a DataFrame extracted from a dictionary called dataSourceDict.
    • Several column names are defined as constants, which are used to identify specific data fields within the DataFrame.
  2. Output DataFrame Preparation
    • A new DataFrame, outputDf, is created by copying inputDf. This ensures that the original data remains unchanged while modifications are made to the copy.
    • The script initializes the ‘AUTOMATION - Outlier’ column in outputDf by setting its values to an empty string, effectively clearing any existing data in this column.
  3. Data Display
    • The script concludes by printing the first few rows of outputDf using the tableize function, which formats the DataFrame for display. This step is useful for verifying that the column has been successfully cleared.

Vitals

  • Script ID : 1125
  • Client ID / Customer ID: 1306927757 / 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 16:57
  • Last Updated by dwaidhas@marinsoftware.com on 2024-05-22 16:57
> 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