Skip to content

Done Pandas3#59

Open
sakshiasati17 wants to merge 1 commit intosuper30admin:mainfrom
sakshiasati17:main
Open

Done Pandas3#59
sakshiasati17 wants to merge 1 commit intosuper30admin:mainfrom
sakshiasati17:main

Conversation

@sakshiasati17
Copy link

No description provided.

@super30admin
Copy link
Owner

Let me evaluate each solution file separately:

  1. CalculateSpecialBonus.py:
  • Correctness: The logic appears correct for calculating bonus based on employee_id being odd and name not starting with 'M'.
  • Time Complexity: O(n) where n is number of employees, which is optimal.
  • Space Complexity: O(n) for storing results, which is necessary.
  • Code Quality: The solution could be improved by using pandas vectorized operations instead of iterating through rows. For example, using np.where() or boolean masking would be more idiomatic pandas.
  • Efficiency: The current implementation is less efficient than pandas vectorized operations.
  1. FixNamesInATable.py:
  • Correctness: The solution correctly capitalizes first letter and makes rest lowercase.
  • Time Complexity: O(n) which is optimal.
  • Space Complexity: O(1) as it modifies in-place.
  • Code Quality: Clean and concise, good use of pandas string methods.
  • Efficiency: Very efficient pandas vectorized approach.
  1. PatientsWithACondition.py:
  • Correctness: The logic for finding DIAB1 conditions appears correct, but may miss some edge cases where DIAB1 appears in the middle of a word.
  • Time Complexity: O(n*m) where n is patients and m is conditions per patient - could be optimized.
  • Space Complexity: O(n) for storing results.
  • Code Quality: Again using iteration, which is less pandas-idiomatic. Could use str.contains() with regex.
  • Efficiency: The nested loop makes this less efficient than possible with pandas string operations.

General improvements needed:

  • Avoid iterating through DataFrames with for loops when pandas vectorized operations are available
  • Consider edge cases more thoroughly (like DIAB1 in middle of word)
  • Consistent formatting (some extra whitespace in files)
  • More pandas-idiomatic solutions would be preferable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants