title: How to store an image in pandas dataframe column?
body: <p>I have the following line of code.</p>
  
  <pre><code>v = chemcepterize_mol(mol, embed=10, res=0.2)
  </code></pre>
  
  <p>The function <code>chemcepterize_mol</code> takes some arguments like <code>mol, embed, res</code>.
  This function <code>chemcepterize_mol</code> return a value which i store in <code>v</code> which is an ordinary variable.</p>
  
  <p>This <code>v</code> is actually a vector representing three dimensional image. </p>
  
  <p>The shape of the <code>v</code>  is as follows.</p>
  
  <pre><code>print(v.shape) 
  (100, 100, 4)
  </code></pre>
  
  <p>100X100 pixels image with 4 channels.</p>
  
  <p>When I show this image, It looks like below.</p>
  
  <pre><code>plt.imshow(v[:,:,:3])
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/m50u0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m50u0.png" alt="100x100x4 image"></a></p>
  
  <p>Up to this point, it works fine. But I have few of these types of images (3 dimensional vectors) which I need to store in my dataframe. That means, I need to call this function <code>chemcepterize_mol</code>  few times, lets say 10 times to obtain 10 images. </p>
  
  <p>For that I wrote a for loop like this below.</p>
  
  <pre><code>v = np.ndarray(shape=(100,100, 4,1))
  for x in range(10):
  
     v[x]=chemcepterize_mol(data["mol"][x],embed=10,res=0.2)
  </code></pre>
  
  <p>Here, <code>data["mol"][x]</code>is the <code>x</code> entry of the column <code>mol</code> in my data frame <code>data</code>. For each of these <code>data["mol"][x]</code> values , the <code>chemcepterize_mol</code> will give me a different 3 dimensional vector which I need to store.</p>
  
  <p>I declared  <code>v = np.ndarray(shape=(100,100, 4,1))</code> so that in it's last dimension, I can store all my vectors (images), but it it given me this error.</p>
  
  <pre><code>ValueError: could not broadcast input array from shape (100,100,4) into shape (100,4,1)
  </code></pre>
  
  <p>How can I store all my vectors in some array or preferably in separate pandas data frame column.</p>