Batch LabMedium
Lab: Banking Transactions
Estimated time: 30 mins
Who This Lab Is For
Intermediate developers looking to design audit records and sign-adjusted financial aggregations.
What You Will Learn
- How to transform string actions (deposit vs withdrawal) into positive/negative floats.
- How to group transactions and aggregate net balance changes per account.
- How to output clean accounting records.
1. Business Scenario
Audit accounts by summing deposits and withdrawals.
2. Input Dataset (\`dataset.csv\`)
Save the following raw rows locally as \`dataset.csv\` to test your pipeline:
text
account_id,type,amount
acct1,deposit,1500.00
acct2,withdrawal,200.00
acct1,withdrawal,100.00
acct3,deposit,3000.00
acct2,deposit,500.003. Starter Code Skeleton
Create a local file named \`starter.py\` and copy the following skeleton. Complete the missing transformations:
python
# starter.py - Banking Transactions
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
def run_pipeline():
options = PipelineOptions()
with beam.Pipeline(options=options) as p:
# TODO: Map transaction type to positive/negative values
# TODO: Calculate net change per account
pass
if __name__ == "__main__":
run_pipeline()4. Lab Requirements
- Convert transaction amounts to positive (deposits) or negative (withdrawals).
- Group balance changes by account ID.
- Calculate the net balance adjustment per account.
5. Step-by-Step Guide & Solution
Advertisement
AdSense Slot #847392Leaderboard Banner (728x90)