-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_input.py
30 lines (24 loc) · 1.05 KB
/
read_input.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
"""
Utility function to parse the input table (in a CSV file) to compute entitlements and values.
"""
import pandas
def get_input_from_raw_table(df:pandas.DataFrame)->tuple:
entitlements = []
for i in range(len(df)):
incoming_relative_ownership = df["in_relative_ownership"][i]
if (str(incoming_relative_ownership) != "nan"):
entitlements.append(float(incoming_relative_ownership))
sumentitlements = sum(entitlements)
entitlements = [e / sumentitlements for e in entitlements]
print("sumentitlements = ",sumentitlements)
values = []
for i in range(len(df)):
values.append(int(df["out_due_value_absolute"][i].replace(',', '')))
return entitlements, values
if __name__=="__main__":
df = pandas.read_csv('rishon-letzion.csv')
print("Raw table: ", df, "\n")
entitlements,values = get_input_from_raw_table(df.head(10))
# entitlements,values = get_input_from_raw_table(df)
print(len(values), " items: ", values, "\n")
print(len(entitlements), " entitlements: ", entitlements, "\n")