Script 789: Remove $ from SBA Campaign Budget
Purpose
Remove the dollar sign ($) from the SBA Campaign Budget column in a given input dataframe.
To Elaborate
The Python script aims to remove the dollar sign ($) from the SBA Campaign Budget column in a given input dataframe. The SBA Campaign Budget column contains budget values for different campaigns, but some of the values have a dollar sign ($) at the beginning. This script removes the dollar sign ($) from those values, ensuring that the budget values are in a consistent format for further analysis or processing.
Walking Through the Code
- The input dataframe is retrieved from the
dataSourceDict
dictionary using the key “1”. - The script defines the names of the output columns and their initial values.
- The dollar sign ($) is removed from the beginning of values in the
RPT_COL_SBA_CAMPAIGN_BUDGET
column in the input dataframe. - Only non-empty rows in the
BULK_COL_SBA_CAMPAIGN_BUDGET
column of the output dataframe are included. - The dollar sign ($) is removed from the beginning of values in the
BULK_COL_SBA_CAMPAIGN_BUDGET
column in the output dataframe. - If the output dataframe is not empty, it is printed in a tabular format using the
tableize()
function. Otherwise, the message “Empty outputDf” is printed.
Vitals
- Script ID : 789
- Client ID / Customer ID: 1306926629 / 60270083
- Action Type: Bulk Upload
- Item Changed: Campaign
- Output Columns: Account, Campaign, SBA Campaign Budget
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: dwaidhas@marinsoftware.com (dwaidhas@marinsoftware.com)
- Created by dwaidhas@marinsoftware.com on 2024-03-08 22:11
- Last Updated by dwaidhas@marinsoftware.com on 2024-03-08 22:14
> 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
34
##
## name: Remove $ from SBA Campaign Budget
## description:
##
##
## author:
## created: 2024-03-08
##
inputDf = dataSourceDict["1"]
# Output columns and initial values
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_SBA_CAMPAIGN_BUDGET = 'SBA Campaign Budget'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_SBA_CAMPAIGN_BUDGET = 'SBA Campaign Budget'
# Remove '$' from the beginning of values in the RPT_COL_SBA_CAMPAIGN_BUDGET column in inputDf
inputDf[RPT_COL_SBA_CAMPAIGN_BUDGET] = inputDf[RPT_COL_SBA_CAMPAIGN_BUDGET].str.replace('$', '')
# Only include non-empty tags in bulk
outputDf = outputDf.dropna(subset=[BULK_COL_SBA_CAMPAIGN_BUDGET])
# Remove '$' from the beginning of values in the BULK_COL_SBA_CAMPAIGN_BUDGET column in outputDf
outputDf[BULK_COL_SBA_CAMPAIGN_BUDGET] = outputDf[BULK_COL_SBA_CAMPAIGN_BUDGET].str.replace('$', '')
if not outputDf.empty:
print("outputDf", tableize(outputDf))
else:
print("Empty outputDf")
Post generated on 2024-03-10 06:34:12 GMT