title: Run same operation on multiple columns with assign?
body: <p>I am looking for a short way to run the same operation on multiple columns - typically by running it through <code>.assign</code>.</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  
  df = pd.DataFrame({'a':[' abc ', 'efg', ' hij'], 'b': [' kkk ', 'eee', 'uuu ']})
  </code></pre>
  <p>In this example I have two columns with strings, some of which have leading and trailing spaces. If I want to remove them I would do something like this:</p>
  <pre><code>df.assign(a=lambda x: x[&quot;a&quot;].str.strip(), b=lambda x: x[&quot;b&quot;].str.strip())
  </code></pre>
  <p>basically repeating the same lambda expression for every column. Is there a more convenient way? I do not want to run a loop, because that cannot be method-chained.</p>
  <p>My first idea was something like this, following the &quot;don't repeat yourself&quot; principle:</p>
  <pre><code>df.assign({col : lambda x: x[col].str.strip() for col in ['a', 'b']})
  </code></pre>
  <p>which of course does not work.</p>
  <p>Any suggestions very welcome!</p>