Skip to content

Added Pandas1 Q1–Q4 solutions#69

Open
arushi2106 wants to merge 2 commits intosuper30admin:mainfrom
arushi2106:main
Open

Added Pandas1 Q1–Q4 solutions#69
arushi2106 wants to merge 2 commits intosuper30admin:mainfrom
arushi2106:main

Conversation

@arushi2106
Copy link

No description provided.

@super30admin
Copy link
Owner

The student has provided solutions to four different problems using pandas, demonstrating a good understanding of DataFrame operations. Here's a detailed evaluation of each solution:

  1. Big_Countries.ipynb:

    • Correctness: The solution correctly filters countries based on area or population criteria.
    • Time Complexity: O(n) where n is the number of rows in the DataFrame (due to the filtering operation).
    • Space Complexity: O(m) where m is the number of rows that meet the criteria (new DataFrame is created).
    • Code Quality: The code is clean and straightforward. The use of chained operations is appropriate here.
    • Efficiency: No major optimizations needed for this simple filtering operation.
  2. Customers_Who_Never_Order.ipynb:

    • Correctness: The solution correctly identifies customers who never placed orders using a left merge and NA check.
    • Time Complexity: O(n + m) for the merge operation where n and m are sizes of the DataFrames.
    • Space Complexity: O(n + m) for the merged DataFrame.
    • Code Quality: Good use of merge operation and column renaming. The logic is clear.
    • Efficiency: Could potentially use ~customers['id'].isin(orders['customerId']) for better performance with large datasets.
  3. Recylable_products.ipynb:

    • Correctness: Correctly filters products that are both low fat and recyclable.
    • Time Complexity: O(n) for the filtering operation.
    • Space Complexity: O(m) where m is the number of matching products.
    • Code Quality: Simple and effective. The boolean conditions are clearly expressed.
    • Efficiency: No optimizations needed for this straightforward filtering.
  4. pandas1.ipynb:

    • Correctness: Correctly creates a DataFrame from a list of lists.
    • Time Complexity: O(n) where n is the number of elements in the list.
    • Space Complexity: O(n) for the resulting DataFrame.
    • Code Quality: Basic but correct demonstration of DataFrame creation. Could benefit from more context or problem statement.

General Observations:

  • The student demonstrates solid pandas skills across different types of operations.
  • All solutions follow Python naming conventions and are well-structured.
  • Type hints are used appropriately in function definitions.
  • The solutions handle the core requirements effectively.
  • For production code, adding docstrings to explain the functions' purposes would be beneficial.

Areas for Improvement:

  • Consider adding comments or docstrings to explain complex operations.
  • For the customers problem, the alternative solution using isin() might be more efficient for very large datasets.
  • The pandas1.ipynb file seems to be just a demonstration rather than solving a specific problem.

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