title: Pandas- How can I eliminate trailing whitespace in the index
body: <pre><code>df = pd.DataFrame({'A' : ['one', 'two three', 'f four   ', 'three '], 'B': [10,20,30,40]})
  
  df = df.set_index('A')
  </code></pre>
  
  <p>Here is what the df needs to be:</p>
  
  <pre><code>            B
  A   
  one        10
  two three  20
  f four     30
  three      40
  </code></pre>
  
  <p>In the final data frame, the spaces in indices should be removed if they are trailing. If they are anywhere else, they need to remain. So the trailing spaces in 'three ' and 'f four   ' need to be deleted. </p>