samirsaci/graph-theory

Multiple Errors in Code Execution: NameError and ImportError in Visualization Scripts

Opened this issue · 0 comments

Description:
I've encountered several issues while executing the code related to visualizing delivery routes and city connections. Below are the details of the errors:

  1. ImportError: openpyxl module missing
    File: data/store province.xlsx
    Issue: When attempting to read an Excel file using pandas.read_excel, the code fails due to the missing openpyxl module. This is required for reading Excel files in pandas.
    Solution: The openpyxl module should be added to the requirements.txt file.

  2. TypeError: datetime64 type does not support sum operations**
    File: Visualization script for delivery routes
    Issue: The df_an.groupby(['Size']).sum() method throws an error due to the presence of datetime64 types in the DataFrame, which do not support sum operations.
    Solutin: Filter out datetime64 columns or convert them to a different data type before performing the sum operation.

  3. NameError: df_del2 is not defined
    File: Visualization of delivery routes by month
    Issue: The code references df_del2, which is not defined in the provided context, leading to a NameError. This occurs in several parts of the code.
    Solution: It seems df_del2 should be replaced with the correct variable, such as df_del4, that contains the data.

  4. General Recommendation:
    It might be helpful to provide a comprehensive requirements.txt file that includes all necessary dependencies for the project, along with clear instructions on setting up the environment.

Steps to Reproduce:

  1. Run the code blocks related to reading Excel files and visualizing delivery routes.
  2. Observe the ImportError due to the missing openpyxl module.
  3. Execute the groupby operation on datetime64 data types and note the TypeError.
  4. Attempt to use df_del2 in the provided code and observe the NameError.

Environment:

  • Python version: 3.x
  • Libraries: pandas, matplotlib, networkx, etc.
  • Environment: Conda/virtualenv with all dependencies installed except openpyxl.