How can you convert a single df column to a list of lists? using the df below, how can you return X
to a list of lists.
df = pd.DataFrame({
'X' : [1,2,3,4,5,2,3,4,5,6],
'Y' : [11,12,13,14,15,11,12,13,14,15],
})
l = df['X'].values.tolist()
[1, 2, 3, 4, 5, 2, 3, 4, 5, 6]
Converting two columns is possible:
l = df.values.tolist()
[[1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15]]
But I just want X.
[[1], [2], [3], [4], [5], [2], [3], [4], [5], [6]]