Pandas list of list column to Python list

  Kiến thức lập trình

I want to create a list from a Pandas column formatted like so:

col
[[a, b, c], [a,b]]
[[a, b], [c]]
[[x]]

The result should be something like this:

[[['a', 'b', 'c'], ['a', 'b'],
 [['a', 'b'], ['c]],
 [['x']]]

So basically a List[List[List[Str]]]. Doing it with a normal list would be something simple like df.str.split().tolist(), but I have no clue how to do it for this case. Thanks a lot in advance!

LEAVE A COMMENT