hello I have a df such as
COL1
NW_011625257.1_0
NW_011623521.1_1
NW_011623521.3_1
NW_011623521.4_1
NW_011623521.1
JZSA01007324.1_2
scaffold_1463_2
scaffold_1463
and I would like to cut by the last '_' and get
COL1 COL2
NW_011625257.1 0
NW_011623521.1 1
NW_011623521.3 1
NW_011623521.4 1
NW_011623521.1 NaN
JZSA01007324.1 2
scaffold_1463 2
scaffold_1463 NaN
So far i tried :
df[['COL1','COL2']] = df.COL1.str.split(r'_(?!.*_)', expand=True)
instead I get this kind of output:
COL1 COL2
NW_011625257.1 0
NW_011623521.1 1
NW_011623521.3 1
NW_011623521.4 1
NW 011623521.1
JZSA01007324.1 2
scaffold_1463 2
scaffold 1463
here is an exemple of what I want to select

NaN? What do you expect?r"(?<=\.\d)_(?!.*_)"(?<=[0-9])_works