Pandas Split Function in Reverse

后端 未结 3 759
遥遥无期
遥遥无期 2021-01-15 08:46

I have a Pandas Dataframe with a column that looks like this:

    Car_Make
0   2017 Abarth 124 Spider ManualConvertible
1   2017 Abarth 124 Spider AutoConver         


        
3条回答
  •  一生所求
    2021-01-15 09:12

    Is this what you are looking for:

    df.car_make.str.rsplit(' ', 1, expand=True)
    # returns:
                            0                  1
    0  2017 Abarth 124 Spider  ManualConvertible
    1  2017 Abarth 124 Spider    AutoConvertible
    2  2017 Abarth 124 Spider  ManualConvertible
    3  2017 Abarth 124 Spider    AutoConvertible
    4         2017 Abarth 595        ManualHatch
    5         2017 Abarth 595          AutoHatch
    

提交回复
热议问题