Split pandas column and add last element to a new column
If need create 2 new columns, use str.rsplit
with parameter n=1
. If need only last column, EdChum
solution is better:
print (df) fullname0 martin master1 andreas test2 andreas martin masterdf[['first_name','last_name']] = df['fullname'].str.rsplit(expand=True, n=1)print (df) fullname first_name last_name0 martin master martin master1 andreas test andreas test2 andreas martin master andreas martin master