title: Python: unsupported operand type(s) for /: 'tuple' and 'float'
body: <p>I'm trying to loop and create a new data frame based on another data frame I have. Suppose I have a dataframe like this</p>
  
  <pre><code>Foo Fizz Buzz totals scale
  10  3    2     15     .2
  8   4    3     15     .2 
  5   1    5     11     .4
  6   7    5     18     .1
  9   2    6     17     .1
  </code></pre>
  
  <p>And a categorical variable as such:</p>
  
  <pre><code>groups = pd.Series(['Foo','Fizz','Buzz'], dtype = "category")
  </code></pre>
  
  <p>And I want to create a new dataframe where it takes the percentage of the total and multiply it by the scale. I figured the easiest way is to loop it so I can have the dataframe and names consistent but it's throwing me this error:</p>
  
  <pre><code>TypeError: unsupported operand type(s) for /: 'tuple' and 'float'
  </code></pre>
  
  <p>The code I used is below. Any help would be appreciated (I know there has to be an easier way). Thanks!</p>
  
  <pre><code>df = pd.DataFrame() #creating an empty data frame 
  for j in Categorical(groups).categories: #looping through categories
      calc = [] #empty list
      for i in range(0, demo.shape[0]): #loop through rows
          #Below is basically the column divided by the total and multiplied by the scale. 
          #Then take that number and append it onto the list                    
          calc.append(round((round(cross.ix[i,j],4)/round(cross.totals[i],4)) * cross.weight[i],4))
  
          #finally append this list to the dataframe using the categories as the column name using setting with enlargement 
          df.loc[:,Categorical(groups).categories[j]] = calc 
  </code></pre>