How to convert a column to a non-nested list while the column elements are list?
For example, the column is like
column
[1, 2, 3]
[1, 2]
<
We concatenate lists with the +
operator. Because a pandas series uses its' elements underlying +
operation when you call pd.Series.sum
, we can concatenate a whole column, or series, of lists with.
df.column.sum()
[1, 2, 3, 1, 2]
But if you're looking for performance, you can consider cytoolz.concat
import cytoolz
list(cytoolz.concat(df.column.values.tolist()))
[1, 2, 3, 1, 2]