title: How to reverse strings in pandas dataframe?
body: <p>My dataframe is like,</p>
  
  <pre><code>ID   col1
  1    Michael Owen
  2    Stephen Curry
  3    Messi, Lionel
  4    James, LeBron
  </code></pre>
  
  <p>I tried to reverse the order of those names which were split by <code>", "</code> .</p>
  
  <p>My code is,</p>
  
  <p><code>df['col1'] = df.col1.str.split().apply(lambda x: ', '.join(x[::-1]))</code></p>
  
  <p>But it reverses all rows even the names were split by <code>" "</code>. </p>
  
  <pre><code>ID   col1
  1    Owen, Michael
  2    Curry, Stephen
  3    Lionel, Messi
  4    LeBron, James
  </code></pre>
  
  <p>Then I tried</p>
  
  <p><code>df.loc[df['col1'].str.contains(", ").split("col1")].apply(lambda x: ', '.join(x[::-1]))</code></p>
  
  <p>It gives me an error,</p>
  
  <pre><code>AttributeError: 'Series' object has no attribute 'split'
  </code></pre>
  
  <p>How can I solve this problem?</p>