Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions FEEDBACK.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Feedback

1. Your team:
2. Name of each individual participating:
3. How many unit tests were you able to pass?
1. Your team: Minh Nguyen
2. Name of each individual participating: Minh Nguyen
3. How many unit tests were you able to pass? I was able to past the first two sets
4. Document and describe any enhancements included to help the judges properly grade your submission.
- Example One
- Example Two
Expand Down
103 changes: 85 additions & 18 deletions python/simple_data_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,28 @@ def get_num_closed_claims(self):
Returns:
int: number of closed claims
"""
pass
closed_claim_counter = 0
claim_data = self.get_claim_data(self)
for claim in claim_data:
if claim.status == "Closed":
closed_claim_counter+= 1

return closed_claim_counter

def get_num_claims_for_claim_handler_id(self, claim_handler_id):
"""Calculates the number of claims assigned to a specific claim handler

Args:
claim_handler_id (int): id of claim handler

Returns:
int: number of claims assigned to claim handler
"""
pass
claim_data = self.get_claim_data(self)
num_claim_to_handler = 0
for claim in claim_data:
if claim.claim_handler_assigned_id == claim_handler_id:
num_claim_to_handler += 1
return num_claim_to_handler

def get_num_disasters_for_state(self, state):
"""Calculates the number of disasters for a specific state
Expand All @@ -82,7 +92,13 @@ def get_num_disasters_for_state(self, state):
Returns:
int: number of disasters for state
"""
pass

disasters = self.get_disaster_data(self)
num_disaster_of_state = 0
for disaster in disasters:
if disaster.state == state:
num_disaster_of_state += 1
return num_disaster_of_state

# endregion

Expand All @@ -98,9 +114,14 @@ def get_total_claim_cost_for_disaster(self, disaster_id):
float | None: estimate cost of disaster, rounded to the nearest hundredths place
returns None if no claims are found
"""

pass

claims = self.get_claim_data()
claims_by_disaster_id = filter(lambda claim: claim["disaster_id"] == disaster_id, claims)
if len(list(claims_by_disaster_id)) == 0: return None
total_claim = 0
for item in claims_by_disaster_id:
total_claim += item["estimate_cost"]
return round(total_claim, 2)

def get_average_claim_cost_for_claim_handler(self, claim_handler_id):
"""Gets the average estimated cost of all claims assigned to a claim handler

Expand All @@ -111,8 +132,11 @@ def get_average_claim_cost_for_claim_handler(self, claim_handler_id):
float | None : average cost of claims, rounded to the nearest hundredths place
or None if no claims are found
"""

pass
claims = self.get_claim_data()
claims_by_handler_id = filter(lambda claim: claim["claim_handler_assigned_id"] == claim_handler_id, claims)
if len(list(claims_by_handler_id)) == 0: return None
all_costs = [item["estimate_cost"] for item in claims_by_handler_id]
return round(mean(all_costs), 2)

def get_state_with_most_disasters(self):
"""Returns the name of the state with the most disasters based on disaster data
Expand All @@ -127,7 +151,15 @@ def get_state_with_most_disasters(self):
Returns:
string: single name of state
"""
pass
disasters = self.get_disaster_data()
hash_state_disaster_count = {}
for d in disasters:
if d["state"] not in hash_state_disaster_count:
hash_state_disaster_count[d["state"]] = 1
hash_state_disaster_count[d["state"]] += 1
hash_state_disaster_count = dict(sorted(hash_state_disaster_count.items(), key=lambda item: item[0]))
key_with_max_value = max(hash_state_disaster_count, key=hash_state_disaster_count.get)
return key_with_max_value

def get_state_with_least_disasters(self):
"""Returns the name of the state with the least disasters based on disaster data
Expand All @@ -142,7 +174,15 @@ def get_state_with_least_disasters(self):
Returns:
string: single name of state
"""
pass
disasters = self.get_disaster_data()
hash_state_disaster_count = {}
for d in disasters:
if d["state"] not in hash_state_disaster_count:
hash_state_disaster_count[d["state"]] = 1
hash_state_disaster_count[d["state"]] += 1
hash_state_disaster_count = dict(sorted(hash_state_disaster_count.items(), key=lambda item: item[0]))
key_with_min_value = min(hash_state_disaster_count, key=hash_state_disaster_count.get)
return key_with_min_value

def get_most_spoken_agent_language_by_state(self, state):
"""Returns the name of the most spoken language by agents (besides English) for a specific state
Expand All @@ -154,7 +194,18 @@ def get_most_spoken_agent_language_by_state(self, state):
string: name of language
or empty string if state doesn't exist
"""
pass
agents = self.get_agent_data()
agents_by_state = filter(lambda agent: agent["state"] == state, agents)
hash_agents_count_by_lang = {}
for agent in agents_by_state:
if agent["secondary_language"] not in hash_agents_count_by_lang:
hash_agents_count_by_lang[agent["secondary_language"]] = 1
hash_agents_count_by_lang[agent["secondary_language"]] += 1

hash_agents_count_by_lang = dict(sorted(hash_agents_count_by_lang.items(), key=lambda item: item[0]))
if hash_agents_count_by_lang == {}: return ''
key_with_max_value = max(hash_agents_count_by_lang, key=hash_agents_count_by_lang.get)
return key_with_max_value

def get_num_of_open_claims_for_agent_and_severity(self, agent_id, min_severity_rating):
"""Returns the number of open claims for a specific agent and for a minimum severity level and higher
Expand All @@ -170,8 +221,15 @@ def get_num_of_open_claims_for_agent_and_severity(self, agent_id, min_severity_r
-1 if severity rating out of bounds
None if agent does not exist, or agent has no claims (open or not)
"""

pass
if min_severity_rating < 1 and min_severity_rating > 10: return -1
claims = self.get_claim_data()
claims_by_agent_id = filter(lambda claim: claim["claim_handler_assigned_id"] == agent_id, claims)
if len(list(claims_by_agent_id)) == 0: return None
open_claim_count = 0
for claim in claims_by_agent_id:
if claim["status"] != "Closed" and claim["severity_rating"] >= min_severity_rating:
open_claim_count += 1
return open_claim_count

# endregion

Expand All @@ -197,6 +255,8 @@ def build_map_of_agents_to_total_claim_cost(self):
Returns:
dict: key is agent id, value is total cost of claims associated to the agent
"""

agent_claim_cost = {}

pass

Expand All @@ -221,10 +281,7 @@ def calculate_disaster_claim_density(self, disaster_id):
# region TestSetFour

def get_top_three_months_with_highest_num_of_claims_desc(self):
"""Gets the top three months with the highest number of claims

OPTIONAL! OPTIONAL! OPTIONAL!
AS OF 9:21CDT, TEST IS OPTIONAL. SEE GITHUB ISSUE #8 FOR MORE DETAILS
"""Gets the top three months with the highest total claim cost

Hint:
Month should be full name like 01 is January and 12 is December
Expand All @@ -238,3 +295,13 @@ def get_top_three_months_with_highest_num_of_claims_desc(self):
pass

# endregion

test_class = SimpleDataTool()
# print(test_class.get_total_claim_cost_for_disaster(0))
# print(test_class.get_average_claim_cost_for_claim_handler(2))
# print(test_class.get_state_with_most_disasters())
# print(test_class.get_state_with_least_disasters())
# print(test_class.get_most_spoken_agent_language_by_state("Wisconsin"))
print(test_class.get_num_of_open_claims_for_agent_and_severity(24, 1))