I want to delete a substring between a '+' and a '@' symbol together with the '+, if the '+' exists.
d = {'1' : 'dsjlskdgj+fdfsd@test.com', '2' : 'qwioept@test.com', '3' : 'dccnvmxcv+fas@test.com', '4':'dqlt@test.com'}
test_frame = pd.Series(d)
test_frame
Out[6]:
1 dsjlskdgj+fdfsd@test.com
2 qwioept@test.com
3 dccnvmxcv+fas@test.com
4 dqlt@test.com
dtype: object
So, the result should be:
s = {'1' : 'dsjlskdgj@test.com', '2' : 'qwioept@test.com', '3' : 'dccnvmxcv@test.com', '4':'dqlt@test.com'}
test_frame_result = pd.Series(s)
test_frame_result
Out[10]:
1 dsjlskdgj@test.com
2 qwioept@test.com
3 dccnvmxcv@test.com
4 dqlt@test.com
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!