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

  1. Data Source Initialization
    • The script begins by defining the primary data source, inputDf, which is retrieved from a dictionary dataSourceDict using a specific key "2_2". This data frame serves as the source of offline booking data.
  2. Data Frame Copying
    • A new data frame, outputDf, is created by copying inputDf. 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 of inputDf, ensuring consistency in data structure.
  3. Custom Output Columns
    • The script includes a parameter skip_output_validations set to True, which allows users to define custom output columns without being restricted by validation rules. This provides flexibility in how the output data is structured.
  4. Output Display
    • The script concludes by printing the first few rows of outputDf using the tableize function, which formats the data for easy viewing.

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

comments powered by Disqus