I have a dataframe with one of its column having a list at each index. I want to concatenate these lists into one list. I am using
ids = df.loc[0:index, 'User IDs'].values.tolist()
However, this results in
['[1,2,3,4......]']
which is a string. Somehow each value in my list column is type str
. I have tried converting using list()
, literal_eval()
but it does not work. The list()
converts each element within a list into a string e.g. from [12,13,14...]
to ['['1'',','2',','1',',','3'......]']
.
How to concatenate pandas column with list values into one list? Kindly help out, I am banging my head on it for several hours.