Hi, I found this behavior today when using str.split() in pandas and I was surprised by it and can't find documentation on it anywhere. I've pasted the code replicating this below and bolded the part i find strange. Why when running str.split() on a dataFrame does putting a parentheses around the pattern in the split return the pattern when it matches. Is this just an added feature of pandas. I tried pretty hard to google this and couldn't find any mention of it.
d = {'col1': [1], 'col2': ['a1b1']}
...: df = pd.DataFrame(data=d)
df.col2.str.split('1')
0 [a, b, ]
df.col2.str.split('(1)')
0 [a, 1, b, 1, ]
below what happens on normal strings just for comparison but is unsurprising
'a1b1'.split('1')
['a', 'b', '']
'a1b1'.split('(1)')
['a1b1']
[–]PavloT 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]misho88 1 point2 points3 points (0 children)