title: Python Groupby part of a string
body: <p>I'm grouping a list of transactions by UK Postcode, but I only want to group by the first part of the postcode. So, UK post codes are in two parts, outward and inward, separated by a [space]. e.g. W1 5DA.</p>
  
  <pre><code>subtotals = df.groupby('Postcode').count()
  </code></pre>
  
  <p>Is the way I'm doing it now, the way I've thought about doing it at the moment is adding another column to the DataFrame with just the first word of the Postcode column, and then grouping by that... but I'm wondering if there's any easier way to do it.</p>
  
  <p>Thank you</p>