diff options
| author | T-Aji <tolujbd2@gmail.com> | 2024-08-22 10:09:22 +0100 |
|---|---|---|
| committer | T-Aji <tolujbd2@gmail.com> | 2024-08-22 10:09:22 +0100 |
| commit | d04f2474b9b6d3bc11441a1cecfb3cd9e3d67f69 (patch) | |
| tree | 04cf2494f15e0f4bbb8b57705f133164d976abd0 /src/fact-purchase-table.py | |
| parent | 956bc9223a584c9cb687277f9000967f9b3ddc6b (diff) | |
| parent | 5b2b4864eae129e112e70d093eb66498d7de401e (diff) | |
| download | de-project-bentley-d04f2474b9b6d3bc11441a1cecfb3cd9e3d67f69.tar.gz de-project-bentley-d04f2474b9b6d3bc11441a1cecfb3cd9e3d67f69.zip | |
wip: creating dim dataframes
Diffstat (limited to 'src/fact-purchase-table.py')
| -rw-r--r-- | src/fact-purchase-table.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/fact-purchase-table.py b/src/fact-purchase-table.py new file mode 100644 index 0000000..53c0148 --- /dev/null +++ b/src/fact-purchase-table.py @@ -0,0 +1,34 @@ +from src.transform_lambda import read_from_s3_subfolder_to_df, tables +from src.extract_lambda import extract_bucket +import json +import boto3 +import re +import pandas as pd + + +dict_of_df = read_from_s3_subfolder_to_df(tables, extract_bucket(), client=boto3.client("s3")) + + +# iterates through each dataframe in the list of dataframes and assigns them to a variable +df_staff = dict_of_df['staff'] ##no change +df_currency = dict_of_df['currency'] ##scraping API +df_counterparty = dict_of_df['counterparty'] +df_address = dict_of_df['address'] +df_department = dict_of_df['department'] +df_purchase_order = dict_of_df['purchase_order'] + +## dim_staff table is the same across the schemas (no change) + +## dim_counterparty table + +## dim_location df_currency --> drops 2 columns +dim_location = df_address.drop(labels=['created_at', 'last_updated'], axis=1).rename(columns={'address_id': 'location_id'}) + +## dim_counterparty +df_prefixed_address = df_address.add_prefix('counterparty_legal_', axis=1) +pd.merge(df_counterparty, + df_prefixed_address, + left_on="legal_address_id", + right_on="address_id", + how="outer") + |
