title: Pandas GroupBy Function with expanded columns
body: <p>I have the following table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>Brand</th>
  <th>Product</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>Nike</td>
  <td>Shoes</td>
  </tr>
  <tr>
  <td>1</td>
  <td>Nike</td>
  <td>Socks</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Adidas</td>
  <td>Shoes</td>
  </tr>
  <tr>
  <td>3</td>
  <td>Adidas</td>
  <td>Shoes</td>
  </tr>
  <tr>
  <td>4</td>
  <td>Adidas</td>
  <td>Socks</td>
  </tr>
  <tr>
  <td>5</td>
  <td>Flight</td>
  <td>Shorts</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to use the Pandas GroupBy function to produce the following table (totals for rows and columns) to find the number of occurrences that a specific Brand-Product Pair have.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>Shoes</th>
  <th>Socks</th>
  <th>Shorts</th>
  <th>Total</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Nike</td>
  <td>1</td>
  <td>1</td>
  <td>0</td>
  <td>2</td>
  </tr>
  <tr>
  <td>Adidas</td>
  <td>2</td>
  <td>1</td>
  <td>0</td>
  <td>3</td>
  </tr>
  <tr>
  <td>Flight</td>
  <td>0</td>
  <td>0</td>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>Total</td>
  <td>3</td>
  <td>2</td>
  <td>1</td>
  <td>6</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And then want to convert the cells in terms of Percentages:</p>
  <ul>
  <li>The cell % comes from diving the cell value by the column total (e.g., {Shoes, Adidas} = 2/3 = 67% or {Total, Adidas} = 3/6 = 50%)</li>
  </ul>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>Shoes</th>
  <th>Socks</th>
  <th>Shorts</th>
  <th>Total</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Nike</td>
  <td>50%</td>
  <td>50%</td>
  <td>0%</td>
  <td>33%</td>
  </tr>
  <tr>
  <td>Adidas</td>
  <td>67%</td>
  <td>50%</td>
  <td>0%</td>
  <td>50%</td>
  </tr>
  <tr>
  <td>Flight</td>
  <td>0%</td>
  <td>0%</td>
  <td>100%</td>
  <td>17%</td>
  </tr>
  <tr>
  <td>Total</td>
  <td>100%</td>
  <td>100%</td>
  <td>100%</td>
  <td>100%</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Also, on a final note, is there a way to multiply all cell numbers by an adjustment factor (e.g., 0.75)</p>