Nikunj Chawla
Nikunj Chawla

Reputation: 1

How to do I extract values from a pandas series

Suppose I have a pandas series object where each value is a list. How do i change this series to DataFrame with columns say [a,b,c,d,e,f]

Series I have -

0 [0.7142, 0.833334, 1.0, 1.0, 1.0, 1.0]
1 [0.7142, 0.273924, 1.0, 1.0, 1.0, 1.0]

etc

expected dataframe-

id      a      b      c    d    e    f 
0    0.71428 0.833334 1.0  1.0  1.0  1.0 
1    0.71428 0.273924 1.0  1.0  1.0  1.0 

Upvotes: 0

Views: 100

Answers (1)

Bruno Mello
Bruno Mello

Reputation: 4628

IIUC:

pd.DataFrame(list(s), columns = ['a','b', 'c','d','e','f'])

Upvotes: 4

Related Questions