0

I have a dataframe having col2's value being list like

d = {'col1': [1, 2], 'col2': [['a','b','c'],['d','e','f']]}
df = pd.DataFrame(d)
df

col1 col2 0 1 [a, b, c] 1 2 [d, e, f]

I want to convert col2 to a new dataframe

I was able to do like this...

Dataframe = pd.DataFrame()
for i in range(0,df3.shape[0]):
    dff = pd.DataFrame(df3.col2[i]).T
    Dataframe = Dataframe.append(dff)
Dataframe

. 0 1 2 0 a b c 0 d e f

But wondering is there any better way/any Function to convert that column to a new datafarme.?

Shivpe_R
  • 1,022
  • 2
  • 20
  • 31

0 Answers0