Split a dataframe column's list into two dataframe columns

前端 未结 2 1488
迷失自我
迷失自我 2021-01-14 16:20

I\'m effectively trying to do a text-to-columns (from MS Excel) action, but in Pandas.

I have a dataframe that contains values like: 1_1, 2_1, 3_1, and I only want t

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 16:34

    You are close:

    Instead of just splitting try this:

    test2 = pd.DataFrame(test['values'].str.split('_').tolist(), columns = ['c1','c2'])
    

提交回复
热议问题