Script 1495: Offline Booking Data
Purpose
The Python script processes offline booking data by copying it from a primary data source to an output data frame, allowing for custom output columns.
To Elaborate
The script is designed to handle offline booking data by taking an existing data frame from a specified data source and copying it to a new data frame. This process includes setting the column headers of the new data frame to match those of the original. The script allows for flexibility in the output by enabling custom output columns, which means users can modify the output data frame as needed without being constrained by predefined validations. This functionality is particularly useful in scenarios where the data needs to be transformed or customized before further processing or analysis.
Walking Through the Code
- Data Source Initialization
- The script begins by defining the primary data source,
inputDf
, which is retrieved from a dictionarydataSourceDict
using a specific key"2_2"
. This data frame serves as the source of offline booking data.
- The script begins by defining the primary data source,
- Data Frame Copying
- A new data frame,
outputDf
, is created by copyinginputDf
. This ensures that the original data remains unchanged while allowing modifications to the copy. - The column headers of
outputDf
are explicitly set to match those ofinputDf
, ensuring consistency in data structure.
- A new data frame,
- Custom Output Columns
- The script includes a parameter
skip_output_validations
set toTrue
, which allows users to define custom output columns without being restricted by validation rules. This provides flexibility in how the output data is structured.
- The script includes a parameter
- Output Display
- The script concludes by printing the first few rows of
outputDf
using thetableize
function, which formats the data for easy viewing.
- The script concludes by printing the first few rows of
Vitals
- Script ID : 1495
- Client ID / Customer ID: 1306927965 / 60270405
- Action Type: Revenue Upload (Preview)
- Item Changed: None
- Output Columns: Date, Keyword ID, Creative ID, Keyword, Match Type, Group ID, Booking (Conv Date) Conv, Booking (Conv Date) Rev, First Booking (Conv Date) Conv, First Booking (Conv Date) Rev
- Linked Datasource: FTP/Email Feed
- Reference Datasource: Google Sheets
- Owner: Tom McCaughey (tmccaughey@marinsoftware.com)
- Created by Tom McCaughey on 2024-11-07 15:10
- Last Updated by Tom McCaughey on 2024-11-07 15:10
> 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
##
## name: Offline Booking Data
## description:
##
##
## author:
## created: 2024-11-07
##
import datetime
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
# primary data source and columns
inputDf = dataSourceDict["2_2"]
# Copy inputDf to outputDf without changes and set column headers
outputDf = inputDf.copy()
outputDf.columns = inputDf.columns # Set column headers to match those of inputDf
#allow for custom output columns
skip_output_validations = True
# user code start here
print(tableize(outputDf.head()))
Post generated on 2024-11-27 06:58:46 GMT