title: Python pandas insert list into a cell
body: <p>I have a list 'abc' and a dataframe 'df':</p>
  
  <pre><code>abc = ['foo', 'bar']
  df =
      A  B
  0  12  NaN
  1  23  NaN
  </code></pre>
  
  <p>I want to insert the list into cell 1B, so I want this result:</p>
  
  <pre><code>    A  B
  0  12  NaN
  1  23  ['foo', 'bar']
  </code></pre>
  
  <p>Ho can I do that?</p>
  
  <p>1) If I use this:</p>
  
  <pre><code>df.ix[1,'B'] = abc
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>ValueError: Must have equal len keys and value when setting with an iterable
  </code></pre>
  
  <p>because it tries to insert the list (that has two elements) into a row / column but not into a cell.</p>
  
  <p>2) If I use this:</p>
  
  <pre><code>df.ix[1,'B'] = [abc]
  </code></pre>
  
  <p>then it inserts a list that has only one element that is the 'abc' list ( <code>[['foo', 'bar']]</code> ).</p>
  
  <p>3) If I use this:</p>
  
  <pre><code>df.ix[1,'B'] = ', '.join(abc)
  </code></pre>
  
  <p>then it inserts a string: ( <code>foo, bar</code> ) but not a list.</p>
  
  <p>4) If I use this:</p>
  
  <pre><code>df.ix[1,'B'] = [', '.join(abc)]
  </code></pre>
  
  <p>then it inserts a list but it has only one element ( <code>['foo, bar']</code> ) but not two as I want ( <code>['foo', 'bar']</code> ).</p>
  
  <p>Thanks for help!</p>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>My new dataframe and the old list:</p>
  
  <pre><code>abc = ['foo', 'bar']
  df2 =
      A    B         C
  0  12  NaN      'bla'
  1  23  NaN  'bla bla'
  </code></pre>
  
  <p>Another dataframe:</p>
  
  <pre><code>df3 =
      A    B         C                    D
  0  12  NaN      'bla'  ['item1', 'item2']
  1  23  NaN  'bla bla'        [11, 12, 13]
  </code></pre>
  
  <p>I want insert the 'abc' list into <code>df2.loc[1,'B']</code> and/or <code>df3.loc[1,'B']</code>.</p>
  
  <p>If the dataframe has columns only with integer values and/or NaN values and/or list values then inserting a list into a cell works perfectly. If the dataframe has columns only with string values and/or NaN values and/or list values then inserting a list into a cell works perfectly. But if the dataframe has columns with integer and string values and other columns then the error message appears if I use this: <code>df2.loc[1,'B'] = abc</code> or <code>df3.loc[1,'B'] = abc</code>.</p>
  
  <p>Another dataframe:</p>
  
  <pre><code>df4 =
            A     B
  0      'bla'  NaN
  1  'bla bla'  NaN
  </code></pre>
  
  <p>These inserts work perfectly: <code>df.loc[1,'B'] = abc</code> or <code>df4.loc[1,'B'] = abc</code>.</p>