title: Constraint issue with pyomo involving a scalar
body: <p>working on an economic optimization problem with pyomo, I would like to add a constraint to prevent the product of the commodity quantity and its price to go below zero (&lt;0), avoiding a negative revenue. It appears that all the data are in a dataframe and I can't setup a constraint like:</p>
  <pre><code>def positive_revenue(model, t)
      return model.P * model.C &gt;=0
  model.positive_rev = Constraint(model.T, rule=positive_revenue)
  </code></pre>
  <p>The system returns the error that the price is a scalar and it cannot process it. Indeed the price is set as such in the model:</p>
  <pre><code>model.T = Set(doc='quarter of year', initialize=df.quarter.tolist(), ordered=True)
  
  
  
  model.P = Param(initialize=df.price.tolist(), doc='Price for each quarter')
  
  ##while the commodity is:
  model.C = Var(model.T, domain=NonNegativeReals)
  </code></pre>
  <p>I just would like to apply that for each timestep (quarter of hour here) that:</p>
  <p>price(t) * model.C(t) &gt;=0</p>
  <p>Can someone help me to spot the issue ? Thanks</p>
  <p>Here are more information:</p>
  <p>df dataframe:</p>
  <pre><code>df                   time_stamp  price Status  imbalance  
  quarter                                                                                                                                  
  0       2021-01-01 00:00:00  64.84  Final         16          
  1       2021-01-01 00:15:00  13.96  Final         38          
  2       2021-01-01 00:30:00  12.40  Final         46  
  </code></pre>
  <p>index = quarter from 0 till 35049, so it is ok</p>
  <pre><code>Here is the df.info()
  #   Column          Non-Null Count  Dtype         
  ---  ------          --------------  -----         
   0   time_stamp      35040 non-null  datetime64[ns]
   1   price           35040 non-null  float64       
   2   Status          35040 non-null  object        
   3   imbalance       35040 non-null  int64  
  
     
  </code></pre>
  <p>I modified the to_list() &gt; to_dict() in model.T but still facing the same issue:</p>
  <p>KeyError: &quot;Cannot treat the scalar component 'P' as an indexed component&quot; at the time model.T is defined in the model parameter, set and variables.</p>
  <p>Here is the constraint where the system issues the error:</p>
  <pre><code>def revenue_positive(model,t):
          for t in model.T:
              return (model.C[t] * model.P[t]) &gt;= 0
      
      model.positive_revenue = Constraint(model.T,rule=revenue_positive)
  </code></pre>
  <p>Can't figure it out...any idea ?
  <strong>UPDATE</strong>
  Model works after dropping an unfortunate 'quarter' column somewhere...after I renamed the index as quarter.
  It runs but i still get negative revenues, so the constraints seems not working at present, here is how it is written:</p>
  <p>def revenue_positive(model,t):
  for t in model.T:
  return (model.C[t] * model.P[t]) &gt;= 0</p>
  <pre><code>model.positive_revenue = Constraint(model.T,rule=revenue_positive)
  </code></pre>
  <p>What am I missing here ? Thanks for help, just beginning</p>