-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolution.py
35 lines (26 loc) · 919 Bytes
/
solution.py
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
27
28
29
30
31
32
33
34
35
import pandas as pd
import numpy as np
class ChitFund:
def __init__(self, filename):
self.df = pd.read_csv(filename)
self.totalReturn = self.total_return()
def total_return(self):
bid_return = np.array(self.df['Net amount recd by Bid winner'])
each_month_return = np.array(self.df['Amount returned to everyone in the group'])
for i in each_month_return:
bid_return += i
return bid_return
def annual_return(self):
temp = self.totalReturn * (12/25)
return temp
def return_percentage(self):
temp = self.totalReturn * (100 / 50000)
return temp
def main():
C1 = ChitFund('input1.csv')
C1.df['Total Return'] = C1.totalReturn
C1.df['Annualized Return'] = C1.annual_return()
C1.df['Return Percentage'] = C1.return_percentage()
C1.df.to_csv('output.csv')
if __name__ =='__main__':
main()