To solve this optimization problem, we first need to define the decision variables and the objective function. Let's denote the number of containers of nuts as `x` and the number of containers of candy as `y`. The profit per container of nuts is $5, and the profit per container of candy is $3. Therefore, the total profit can be represented as `5x + 3y`.

The constraints are based on the time available for weighing and packaging. Each container of nuts takes 10 minutes of weighing and 5 minutes of packaging, while each container of candy takes 5 minutes of weighing and 8 minutes of packaging. The grocery has 1000 minutes available for weighing and 1500 minutes for packaging. This gives us two constraints:

1. Weighing time constraint: `10x + 5y <= 1000`
2. Packaging time constraint: `5x + 8y <= 1500`

Additionally, the number of containers of nuts and candy cannot be negative, so we have:

3. Non-negativity constraints: `x >= 0` and `y >= 0`

Our goal is to maximize the total profit, which is represented by the objective function `5x + 3y`, subject to these constraints.

Here's how we can represent this problem using Gurobi in Python:

```python
from gurobipy import *

# Create a model
m = Model("Grocery_Optimization")

# Define decision variables
x = m.addVar(lb=0, vtype=GRB.INTEGER, name="nuts")
y = m.addVar(lb=0, vtype=GRB.INTEGER, name="candy")

# Set the objective function to maximize profit
m.setObjective(5*x + 3*y, GRB.MAXIMIZE)

# Add constraints
m.addConstr(10*x + 5*y <= 1000, "weighing_time")
m.addConstr(5*x + 8*y <= 1500, "packaging_time")

# Optimize the model
m.optimize()

# Print the results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Containers of nuts: {x.x}")
    print(f"Containers of candy: {y.x}")
    print(f"Total profit: ${5*x.x + 3*y.x:.2f}")
else:
    print("No optimal solution found")
```