I am looking for an efficient way to remove unwanted parts from strings in a DataFrame column.
Data looks like:
time result
1 09:00 +52A
Suppose your DF is having those extra character in between numbers as well.The last entry.
result time
0 +52A 09:00
1 +62B 10:00
2 +44a 11:00
3 +30b 12:00
4 -110a 13:00
5 3+b0 14:00
You can try str.replace to remove characters not only from start and end but also from in between.
DF['result'] = DF['result'].str.replace('\+|a|b|\-|A|B', '')
Output:
result time
0 52 09:00
1 62 10:00
2 44 11:00
3 30 12:00
4 110 13:00
5 30 14:00