Turn pandas series to series of lists or numpy array to array of lists
<p>I have a series <code>s</code></p>

<pre><code>s = pd.Series([1, 2])
</code></pre>

<p>What is an efficient way to make <code>s</code> look like</p>

<pre><code>0    [1]
1    [2]
dtype: object
</code></pre>

<p>If you want the result to still be a pandas <code>Series</code> you can use the <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.apply.html" rel="nofollow"><code>apply</code></a> method :</p>

<pre><code>In [1]: import pandas as pd

In [2]: s = pd.Series([1, 2])

In [3]: s.apply(lambda x: [x])
Out[3]: 
0    [1]
1    [2]
dtype: object
</code></pre>

python pandas numpy