title: Python: How to assign elements of an array to multiple columns in DataFrame?
body: <p>So, I have a function like below:</p>
  <pre><code>def do_something(row, args):
      # doing something
      return arr 
  </code></pre>
  <p>where <code>arr = array([1, 2, 3, 4, 5])</code></p>
  <p>and in my main function, I have a pandas DataFrame object <code>df</code>, it has columns <code>A, B, C, D, E</code> along with other columns.</p>
  <p>I use function <code>do_something</code> as below, try to assign each of the elements of the returning array to the columns:</p>
  <pre><code>df[['A', 'B', 'C', 'D', 'E']] = df.apply(lambda row: do_something(row, args), axis=1)
  </code></pre>
  <p>However, it gave me an error:</p>
  <blockquote>
  <p>ValueError: Must have equal len keys and values when setting with an
  iterable</p>
  </blockquote>
  <p>I think it means I'm trying to assign the whole array as one variable to multiple columns in my <code>df</code>, hence the unequal length trigger the error. But I'm not sure how to make my goal.</p>