Pandas split column of lists into multiple columns

I have a pandas DataFrame with one column that looks like the following:

    In [207]:df2.teams
    Out[207]: 
    0         [SF, NYG]
    1         [SF, NYG]
    2         [SF, NYG]
    3         [SF, NYG]
    4         [SF, NYG]
    5         [SF, NYG]
    6         [SF, NYG]
    7         [SF, NYG]

I need to split this column of lists into 2 columns named team1 and team2 using pandas.

You can use DataFrame constructor with lists created by converting to numpy array by values with tolist:

    import pandas as pd

    d1 = {'teams': [['SF', 'NYG'],['SF', 'NYG'],['SF', 'NYG'],
                    ['SF', 'NYG'],['SF', 'NYG'],['SF', 'NYG'],['SF', 'NYG']]}
    df2 = pd.DataFrame(d1)
    print (df2)
           teams
    0  [SF, NYG]
    1  [SF, NYG]
    2  [SF, NYG]
    3  [SF, NYG]
    4  [SF, NYG]
    5  [SF, NYG]
    6  [SF, NYG]
    df2[['team1','team2']] = pd.DataFrame(df2.teams.values.tolist(), index= df2.index)
    print (df2)
           teams team1 team2
    0  [SF, NYG]    SF   NYG
    1  [SF, NYG]    SF   NYG
    2  [SF, NYG]    SF   NYG
    3  [SF, NYG]    SF   NYG
    4  [SF, NYG]    SF   NYG
    5  [SF, NYG]    SF   NYG
    6  [SF, NYG]    SF   NYG

And for new DataFrame:

    df3 = pd.DataFrame(df2['teams'].values.tolist(), columns=['team1','team2'])
    print (df3)
      team1 team2
    0    SF   NYG
    1    SF   NYG
    2    SF   NYG
    3    SF   NYG
    4    SF   NYG
    5    SF   NYG
    6    SF   NYG

Solution with apply(pd.Series) is very slow:

    #7k rows
    df2 = pd.concat([df2]*1000).reset_index(drop=True)

    In [89]: %timeit df2['teams'].apply(pd.Series)
    1 loop, best of 3: 1.15 s per loop

    In [90]: %timeit pd.DataFrame(df2['teams'].values.tolist(), columns=['team1','team2'])
    1000 loops, best of 3: 820 µs per loop

From: stackoverflow.com/q/35491274