-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Closed
Copy link
Labels
Description
LeetCode Username
sk1401ipm
Problem Number, Title, and Link
Bug Category
Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)
Bug Description
The problem asks for the sum to be rounded to 2 decimal places.
However, at least for submissions using pandas, there were no test cases to check that.
Language Used for Code
Pandas
Code used for Submit/Run operation
def find_investments(insurance: pd.DataFrame) -> pd.DataFrame:
dup_tiv_2015 = insurance.duplicated(subset='tiv_2015', keep=False)
dup_loc = insurance.duplicated(subset=['lat', 'lon'], keep=False)
mask = dup_tiv_2015 & ~dup_loc
result = insurance[mask]
sum = result.tiv_2016.sum() # to meet requirements, this needs to be sum = round(result.tiv_2016.sum(), 2)
return pd.DataFrame({ 'tiv_2016': [sum] })Expected behavior
There should be a test case to check that the sum was rounded to 2 decimal places.
For example (slight modification to example 1)
| pid | tiv_2015 | tiv_2016 | lat | lon |
| --- | -------- | -------- | --- | --- |
| 1 | 10 | 5.12345 | 10 | 10 |
| 2 | 20 | 20 | 20 | 20 |
| 3 | 10 | 30 | 20 | 20 |
| 4 | 10 | 40 | 40 | 40 |
Screenshots
No response
Additional context
No response