Script 1129: Clear Automation Outlier
Purpose
The Python script is designed to clear the ‘AUTOMATION - Outlier’ column in a data table to reset or prepare it for new data processing.
To Elaborate
The script addresses the need to reset a specific column, ‘AUTOMATION - Outlier’, in a dataset that is likely used for tracking or analyzing outliers in automated processes. This task is essential in data management, especially when preparing datasets for new analyses or ensuring that previous data does not interfere with upcoming operations. The script achieves this by creating a copy of the original dataset and then clearing the specified column, ensuring that the original data remains intact while the working copy is prepared for further use. This process is crucial in maintaining data integrity and ensuring accurate results in subsequent data processing tasks.
Walking Through the Code
- Data Preparation
- The script begins by defining the primary data source and relevant columns from a dictionary object,
dataSourceDict
, which contains the dataset. - It specifies several column names that are used in the dataset, such as ‘Group’, ‘Publisher’, ‘Account’, ‘Campaign’, and ‘AUTOMATION - Outlier’.
- The script begins by defining the primary data source and relevant columns from a dictionary object,
- Output Initialization
- The script initializes the output DataFrame,
outputDf
, by copying the input DataFrame,inputDf
, to ensure that the original data remains unchanged. - It then clears the ‘AUTOMATION - Outlier’ column in the
outputDf
by setting it to an empty string, effectively resetting this column for future data processing.
- The script initializes the output DataFrame,
- Data Display
- Finally, the script prints the first few rows of the modified DataFrame using the
tableize
function to provide a visual confirmation of the changes made to the dataset.
- Finally, the script prints the first few rows of the modified DataFrame using the
Vitals
- Script ID : 1129
- Client ID / Customer ID: 1306913045 / 60268001
- 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 17:45
- Last Updated by dwaidhas@marinsoftware.com on 2024-05-22 17:46
> 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