import numpy as np
import pandas as pd
def my_first_python_model(dbt, session):
dbt configuration
dbt.config(
materialized=‘table’,
description=‘My_first_Python_model’,
tags=[‘python’]
)
# get upstream data
my_first_dbt_model_result = dbt.ref("my_first_dbt_model").to_pandas()
# Additional Python-based transformations
# Concatenate columns 'FirstName', 'MiddleName', and 'LastName' into a new column 'FullName'
my_first_dbt_model_result['FullName'] = my_first_dbt_model_result[['FirstName', 'MiddleName', 'LastName']].apply(lambda x: ' '.join(x.dropna()), axis=1)
# Print the transformed DataFrame
print(my_first_dbt_model_result[['FullName']])
# Return the DataFrame as a dbt table
return my_first_dbt_model_result[['FullName']]