1In [21]:
2
3def func(string):
4 a_new_string =string.replace('- ','_')
5 a_new_string1 =a_new_string.replace('-','_')
6 a_new_string2= a_new_string1.rstrip(' months')
7 return a_new_string2
8
9df['Time'] = df['Time'].apply(func)
10df
11Out[21]:
12 Time
130 2_3
141 1_2
152 10_11
163 4_5