I have a class called transaction that have these attributes
Transaction([time_stamp, time_of_day, day_of_month ,week_day, duration, amount, trans_type,
location])
an example of the data set is as such
timestamp time date weekday duration amount trans_type location
1 0:07 3 thu 2 balance driveup
2 0:07 3 thu 6 20 withdrawal campus a
3 0:20 1 tue 2 357 advance driveup
4 0:26 3 thu 2 20 withdrawal campus b
5 0:26 4 fri 2 35 deposit driveup
There are different transaction types. define in trans_type which are:
advance, balance, deposit, transfer, withdrawal
How do I calculate the percentage types of transaction?
For example, this will be the resulting list:
[('advance', 20), ('balance', 20), ('deposit', 20), ('transfer', 0), ('withdrawal', 40)]
This is what i have tried:
#percentage of the different types of transactions
advance = 0
balance = 0
deposit = 0
transfer = 0
withdrawal = 0
for element in range(len(atm_transaction_list)):
for trans_type in element:
if trans_type == 'advance':
advance += 1
elif trans_type == 'balance':
balance += 1
elif trans_type == 'deposit':
deposit += 1
elif trans_type == 'transfer':
transfer += 1
elif trans_type == 'withdrawal':
withdrawal += 1