I have a series like below,
0 [1, 12, 23]
1 [2, 23, 54]
2 [3, 23]
3 [4]
dtype: object
I want to convert this single series in to dataframe based on the values in list(explode).
Expected Output:
0 1 2
0 1 12 23
1 2 23 54
2 3 23 None
3 4 None None
I tried,
s=pd.Series([[1,12,23],[2,23,54],[3,23],[4]])
s=s.astype(str)
s.str.replace('\[|\]','').str.split(', ',expand=True)
My above code does the job though I'm looking for good way to solve this.