0

List elements split into seperate rows

I have a column in a data frame which is a list ['a', 'b',], now I want to separate the elements of this list into separate rows in the data frame. How can we do it in python?

21st Feb 2019, 8:36 AM
Bishu Giri
Bishu Giri - avatar
5 Answers
+ 3
hi bishu, can you please just ‚extend‘ and explain the data what you have and what you are going to expect? This will help to give a more precise answer. Lothar
22nd Feb 2019, 7:53 PM
Lothar
Lothar - avatar
+ 3
hi, I assume you have a list of lists like this: mylist = [[1, 'a'], [2, 'b'], [3, 'c']] Or here in an other representation but same content: mylist = [ [1, 'a'], [2, 'b'], [3, 'c'] ] Did i understand it right you want to separate like this: listsep1 shows: [1, 2, 3] listsep2 shows: ['a', 'b', 'c'] so this is the result of grabbing first element from each row and put it together in a new list.
1st May 2019, 12:47 PM
Lothar
Lothar - avatar
+ 3
ok, it would be helpful if you could provide me an example from what you are starting with. Then show which steps you plan to do and what the final result should looks like. Please also provide the code and the results you have done so far.
1st May 2019, 3:00 PM
Lothar
Lothar - avatar
+ 1
Bishu Giri Did you solve the problem yet? I have a similar one, just with strings in the column...
30th Apr 2019, 8:18 PM
::sĐș::
::sĐș:: - avatar
+ 1
Actually I first have to separate the 'a' string based on a regex. Each line contains a series of 1 .. n substrings with a specific multi-character delimiter string. And each substring should go in a new row, duplicating the other columns of the original unsplit row...
1st May 2019, 1:06 PM
::sĐș::
::sĐș:: - avatar