I have this dataframe
| A | B | |
|---|---|---|
| 0 | 'a' | ['d1','d2'] |
| 1 | 'b' | ['e1,'e2','e3'] |
So column A contains strings, column B contains lists (or when I look for type(): pandas.core.series.series)
That I want to look like:
| A | B | B | B | |
|---|---|---|---|---|
| 0 | 'a' | 'd1' | 'd2' | |
| 1 | 'b' | 'e1 | 'e2' | 'e3' |
I know how to split strings according to a spliting char with df['B'].str.split('<some separator>', <max size of the list within the cell = 3>, expand=True) but I would like to keep working with lists and not have to convert them to strings first.
I did not find a way to do this, or at least did not managed to modify the found code lines to make it work...
# MWE, the example DataFrame
d = ['d1','d2']; e = ['e1','e2','e3']
df = pd.DataFrame({'A': ['a','b'],'B': [d,e]})
print(type(df[df['A'] == 'a']['B']))
print(df)
Thanks.
![[1]: https://i.stack.imgur.com/I86pE.png](https://i.stack.imgur.com/jlgwZ.png)