I want to delete a substring between a '+' and a '@' symbol together with the '+, if the '+' exists.
d = {'1' : '[email protected]', '2' : '[email protected]', '3' : '[email protected]', '4':'[email protected]'}
test_frame = pd.Series(d)
test_frame
Out[6]:
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
dtype: object
So, the result should be:
s = {'1' : '[email protected]', '2' : '[email protected]', '3' : '[email protected]', '4':'[email protected]'}
test_frame_result = pd.Series(s)
test_frame_result
Out[10]:
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
dtype: object
I tried it with split, but due to the fact that only some lines contain a +, it fails.
Is there an elegant solution without looping through all the lines (in the original dataset there are quite many).
Thanks!