I'm trying to split a column in a pandas dataframe based on a separator character, and obtain the last section.
pandas has the str.rsplit and the str.rpartition functions.
If I try:
df_client["Subject"].str.rsplit("-", 1)
I get
0 [Activity -Location , UserCode]
1 [Activity -Location , UserCode]
and if I try
df_client["Subject"].str.rpartition("-")
I get
0 1 20 Activity -Location - UserCode
1 Activity -Location - UserCode
If I do
df_client["Subject"].str.rpartition("-")[2]
I get
0 UserCode
which is what I want.
To me, str.rsplit seems unintuitive.
After getting the list of the split string, how would I then select the single item that I need?