title: Python DataFrame: Remove/Replace part of a string for all values in a column
body: <p>In a Dataframe &quot;df&quot; I have a column called &quot;Company&quot;. In there I have a list of companies that end with &quot;- CP&quot; the problem is that the spaces are not always in the same place and in some of the entries the dash &quot;-&quot; is missing. I want to remove the &quot;-CP&quot; from all entries.</p>
  <p>Input</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Company</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">Intest Apple - CP</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple -CP</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple-CP</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple - CP</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple CP</td>
  </tr>
  <tr>
  <td style="text-align: left;">Howard P Delta - CP</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Output</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Company</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">Intest Apple</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple</td>
  </tr>
  <tr>
  <td style="text-align: left;">Intest Apple</td>
  </tr>
  <tr>
  <td style="text-align: left;">Howard P Delta</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>This is the code that I have, but when I run it nothing changes</p>
  <pre><code>df['Company'] = df['Company'].str.replace(&quot;-CP'&quot;,&quot;&quot;) 
  df['Company'] = df['Company'].str.replace(&quot;- CP'&quot;,&quot;&quot;) 
  df['Company'] = df['Company'].str.replace(&quot; - CP'&quot;,&quot;&quot;) 
  </code></pre>