Storing lists as values ββin a Pandas DataFrame is usually a mistake because it does not allow you to use the fast vectorized NumPy or Pandas operations.
Therefore, you might be better off converting your DataFrame to lists of numbers into a wider DataFrame with your own NumPy types:
import numpy as np import pandas as pd pa = pd.DataFrame({'a':np.array([[1.,4.],[2.],[3.,4.,5.]])}) df = pd.DataFrame(pa['a'].values.tolist())
Now you can select the first column as follows:
In [36]: df.iloc[:, 0] Out[36]: 0 1.0 1 2.0 2 3.0 Name: 0, dtype: float64
or first row, for example:
In [37]: df.iloc[0, :] Out[37]: 0 1.0 1 4.0 2 NaN Name: 0, dtype: float64
If you want to abandon NaN, use .dropna() :
In [38]: df.iloc[0, :].dropna() Out[38]: 0 1.0 1 4.0 Name: 0, dtype: float64
and .tolist() to get list values:
In [39]: df.iloc[0, :].dropna().tolist() Out[39]: [1.0, 4.0]
but if you want to use NumPy / Pandas for speed, you want to express your calculations as vectorized operations on df itself without converting back to Python lists.