rsplit on pandas series using regular expression not working. I want to split the series based on separator without removing separator.
df2= pd.Series(['Series of Class A','Series of Class B part of Class C','Class D','Class'])
seperator='Class'
data = df2.str.split(r'.(?='+seperator+')', n = 2, expand=True)
result is:
0 1 2
0 Series of Class A None
1 Series of Class B part of Class C
2 Class D None None
3 Class None None
I want to do same thing using rsplit
I tried
data = df2.str.rsplit(r'.(?='+seperator+')', n = 2, expand=True)
Expecting same result using rsplit
0 1 2
0 Series of Class A None
1 Series of Class B part of Class C
2 Class D None None
3 Class None None
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…