title: Python Pandas: selecting 1st element in array in all cells
body: <p>What I am trying to do is select the 1st element of each cell regardless of the number of columns or rows (they may change based on user defined criteria)  and make a new pandas dataframe from the data. My actual data structure is similar to what I have listed below.</p>
  
  <pre><code>       0       1       2
  0   [1, 2]  [2, 3]  [3, 6]
  1   [4, 2]  [1, 4]  [4, 6]
  2   [1, 2]  [2, 3]  [3, 6]
  3   [4, 2]  [1, 4]  [4, 6]
  </code></pre>
  
  <p>I want the new dataframe to look like:</p>
  
  <pre><code>    0   1   2
  0   1   2   3
  1   4   1   4
  2   1   2   3
  3   4   1   4
  </code></pre>
  
  <p>The code below generates a data set similar to mine and attempts to do what I want to do in my code without success (d), and mimics what I have seen in a similar question with success(c ; however, only one column). The link to the similar, but different question is here :<a href="https://stackoverflow.com/questions/26069235/python-pandas-selecting-element-in-array-column">Python Pandas: selecting element in array column</a></p>
  
  <pre><code>import pandas as pd
  
  zz = pd.DataFrame([[[1,2],[2,3],[3,6]],[[4,2],[1,4],[4,6]],
                 [[1,2],[2,3],[3,6]],[[4,2],[1,4],[4,6]]])
  print(zz)
  
  x= zz.dtypes
  print(x)
  
  a = pd.DataFrame((zz.columns.values))
  b = pd.DataFrame.transpose(a) 
  c =zz[0].str[0] # this will give the 1st value for each cell in columns 0
  d= zz[[b[0]].values].str[0] #attempt to get 1st value for each cell in all columns
  </code></pre>